How do you safely use a coding agent with AWS?

November 17, 2026 4 answers
Asked by 5u!marlix_738

I'm looking at using a coding agent to build and debug on AWS. How do you keep credentials and costs under control, and does the AWS agent toolkit offer much beyond a scoped role and the CLI?

Answers

3k+pixelwicket_641

Start with the agent's environment, not just its AWS profile. If the agent can run arbitrary shell commands or Python as your user, it may be able to read your Identity Center session cache even when you point the CLI at a different config file.

Run it in a sandbox that doesn't contain your personal SSO session, then provide short-lived credentials for a role scoped to the task. For diagnostics, that might be a read-only role with an explicit deny on assuming other roles. Command approvals can help, but they get hard to manage when commands can be composed or run through scripts.

Nexmori.4v:

A credential broker or injecting short-lived role credentials into the sandbox could work too. The key is that the agent shouldn't inherit the session that can obtain broader access.

Reply to this answer
p.683+grommetfern

The toolkit isn't automatically a replacement for a carefully scoped role and the CLI. Early versions of the API side were largely a CLI wrapper, so that setup can already cover much of the governance side.

The extra value is giving the agent access to current documentation and other AWS-specific tools, skills, and plugins. That can help when a model suggests an outdated API or misses a configuration detail. Whether that's worth the extra setup depends on what your existing agent already has.

5u!marlix_738:

That helps. So even with the toolkit, I'd still need to think separately about what credentials the agent can reach?

_d64+brackenvisor.8:

Yes. Tool-specific policy controls don't replace isolating credentials from the agent's execution environment.

Reply to this answer
Zelviro.8q

Keep cost in the threat model too. An agent that can deploy resources can make an expensive mistake just as easily as it can make a broken one. Start with read-only access for investigation, and review proposed resource changes before giving it deployment permissions.

Reply to this answer
_w73~drizzlecog.5

Agent-specific policy conditions can help distinguish calls made through the AWS MCP service from other calls. They're useful for restricting that path, but don't assume they cover commands the agent runs directly through the CLI or another tool.

For debugging, check the actual permissions between services as well as the agent's own permissions. For example, a Lambda function may be deployed correctly but still need permission for API Gateway to invoke it.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions