AWS Builder Center
A Practical Guide to AWS Permissions for AI Coding Agents

A Practical Guide to AWS Permissions for AI Coding Agents

Learn how to give an AI coding agent least-privilege AWS access using IAM roles, temporary credentials, and policies, with examples for new AWS projects.

Developer Relations Engineer
 You ask your coding agent to deploy one app. It needs to update a Lambda function, upload a deployment package, and read some logs.
Does it need permission to change every resource in your AWS account?
I have answered that question by attaching  AdministratorAccess  to make an AccessDenied error go away. It worked immediately, which is how these things start.
Short answer: no. Give your agent a dedicated IAM role that allows only the actions and resources for its task, issue it temporary credentials, and check which identity it uses before it touches anything. A prompt such as "do not delete anything" guides the agent but does not limit what AWS permits.
A powerful agent moves fast, and its credentials decide how far that speed can take it. Give it a master key and it can open every door in your account.
If you have a codebase you want on AWS, you do not need to memorize IAM actions to scope your agent. Your coding agent can read the code, work out which permissions it needs, and draft the policies. Your job is to ask the right questions and review what comes back. This guide covers the concepts first, then the prompts, then what to do with the output.
AWS experience details checked November 11, 2026. The new experience is rolling out gradually; your signup and console screens may differ. The examples use fictional resource names.

Can a prompt stop an AI agent from deleting AWS resources?

No. A prompt describes intent, and an IAM policy grants authority.
Imagine giving your agent this instruction:
Deploy the development app. Do not delete anything.
The instruction is useful, but it is a sticky note on the production door. If the agent’s credentials allow deletion, AWS never reads the note.
Three controls work together here:
Control
What it does
Example
Prompt or rules file
Tells the agent how you want it to behave
Show me the deployment plan first
Tool or execution control
Limits what the agent can attempt in its environment
Require approval before a shell command runs
AWS authorization
Decides whether AWS accepts a request from the calling identity
Allow updates to one development function
Use all three. Only AWS Identity and Access Management (IAM) policies still apply when the agent attempts an operation anyway.

Instructions guide behavior. AWS permissions constrain the authority used for an API request.
The  Agent Toolkit for AWS  gives your existing coding agent AWS tools, documentation, and task guidance. It does not grant extra permissions or bypass a denied request, and installing it does not shrink an administrator session to least privilege.

Which identity does an AI coding agent use in AWS?

Whatever tool your agent uses to reach AWS (the AWS Command Line Interface, an SDK, infrastructure-as-code, or Model Context Protocol tools), the request carries credentials for one identity. The tool is a way to reach AWS, not a permission level.
Four terms cover most of what you need:
Term
Plain meaning
Identity
Who is making the request, such as an IAM role session
Credentials
The proof that the identity is who it claims to be
Policy
The rules that say which actions on which resources are allowed or denied
Resource
The thing being accessed, such as a function, bucket, or table
Signing in, even with MFA, tells AWS who you are. It says nothing about whether your permissions are small.  AWS policy evaluation 

Trace the actual credentials and execution path. A project name in a prompt is not an access boundary.
An IAM role hands out temporary credentials to whoever assumes it. Its trust policy controls who may assume it, and its permissions policies control what the session may do. A role name is only a label. Naming a role  ReadOnly  does not make it read-only, just as naming a variable  isSafe  does not make it safe.  IAM roles 
Least privilege means granting only the access the job needs. Swapping root for an IAM identity with  AdministratorAccess  still leaves broad authority. Removing root credentials is only the first step.  IAM security practices 

How does the new AWS project experience change agent access?

If you signed up through the new experience, AWS creates a project that contains an AWS account. You sign in with AWS Builder ID, including through supported social sign-in. That personal identity is separate from the account that holds your resources.  New AWS signup 
You cannot use root-user sign-in in a project account, even after activating advanced features. Skip any tutorial that starts with "log in as root."  Root access and project accounts 
Collaboration in a shared project is broad. The owner and invited team members all have administrator access to the available services. Members cannot change spend limits or invite others, but an invitation is not a read-only grant. Inviting a friend to your development project lets them delete its Lambda function. Invite accordingly.  Project collaboration permissions 
You can create custom IAM roles and users for programmatic access on the free plan, with no paid upgrade or advanced features. They cannot sign in to the console. That gives you a way to build a scoped role for your agent. It does not change the broad permissions of the session you used to set things up.  Compare AWS signup options 
You do not need advanced features for any of this. Activation is irreversible, requires the paid plan, and removes project spend limits. Treat it as a separate decision.  Advanced features 

How do you verify which AWS account an agent is using?

Connect your agent to the right project, then ask it to report the identity it is using. Do this before it creates anything.
To connect, follow the current setup flow:
  1. Open  AWS Settings  and select your development project.
  1. Choose Create and manage cloud infrastructure.
  1. Choose Use your AWS credentials with AI coding tools.
  1. Choose Copy agent prompt, then paste it into your coding agent.
Select the matching project when the browser opens. AWS warns that choosing a different session can connect your profile to another project, and a profile name proves nothing about the account behind it.  Connect an AI coding tool 
Then paste this prompt:
Check which AWS identity you are using right now. Report the account ID,
the caller ARN, and the AWS Region. Do not print any credential values.
Do not create or change anything.
Behind the scenes, the agent runs  aws sts get-caller-identity . The result shows an account ID, an identity ARN (AWS's name for an identity or resource), and a user ID. Compare the account ID and Region with AWS Settings → your project → Overview → Additional Info. This check tells you who is calling. It does not tell you what that caller may do.  GetCallerIdentity reference ,  Project Regions 
Run the same check through each way your agent reaches AWS. A terminal profile and an MCP connection can use different sessions. AWS MCP Server supports browser OAuth and a SigV4 proxy that uses AWS credentials.  AWS MCP authentication options 
Temporary and limited mean different things. Temporary credentials expire. Limited permissions restrict which actions work while the credentials are valid. An administrator session that expires in an hour can still delete everything in the first minute. Browser sign-in also leaves credential caches on your machine, so avoiding long-lived access keys does not mean there is nothing local to protect.  Role session duration ,  CLI credential sources 

How do you find the permissions your codebase needs?

Ask your coding agent to read the code and list them. Two sets of permissions matter, and beginners often merge them into one:
  • Deployment permissions belong to the agent. They cover creating or updating the function, uploading the package, and reading logs.
  • Runtime permissions belong to your app. They cover what the deployed code does, such as reading an S3 bucket or writing to a DynamoDB table.
The agent can look up exact IAM action names in AWS documentation if the AWS MCP Server from the Agent Toolkit is connected. The server provides documentation search and task guidance, so the agent does not have to guess action names from memory.  Service Authorization Reference 
Start with analysis only. Paste this prompt in your project:
Read this codebase and its infrastructure files. List every AWS service it
uses or needs when deployed. Split the list into two parts:
1. Runtime: what the deployed app must be allowed to do.
2. Deployment: what an agent needs to deploy and update it.
For each service, give the exact IAM actions and the resource types, and look
up action names in AWS documentation instead of guessing. Mark any action that
creates, deletes, or changes IAM, or that touches secrets or data. Do not run
AWS commands or change anything.
Then ask for drafts:
Using that list, draft three JSON files and do not create anything:
1. A deployment policy for a role named <app>-agent-dev.
2. A runtime policy for the app's execution role.
3. A trust policy that lets only my current sign-in role assume the
deployment role.
Use exact resource ARNs with placeholders for account ID and Region. Avoid
wildcard actions. Explain each statement in plain English. List anything you
could not determine and anything you left out on purpose.
Expect the first draft to be imperfect. It may allow too much, or leave out an action the deploy needs. A draft you can review beats a policy you wrote from memory, and a missing permission shows up as an error you can fix. A permission that is too broad stays silent.

What do you do with the generated output?

Treat the agent's policies as a proposal. Work through these steps in order.
1. Review it against a checklist.
  • Each  Resource  names specific functions, buckets, tables, or log groups wherever the action supports resource-level permissions. If an action requires  "*" , document why and use supported conditions to narrow it.
  • No  Action  is  "*"  or a service-wide wildcard such as  "lambda:*" .
  • No statement grants  iam:* ,  sts:AssumeRole  on other roles, or  iam:PassRole  on a wildcard.
  • The trust policy names only your own role, not the whole account.
  • The account ID and Region match your project.
2. Ask for a second opinion. A fresh prompt catches things the author missed:
Act as a security reviewer. Read these policies and tell me which statements
are broader than the app needs, which could be used to gain more access, and
which use wildcards. Suggest narrower versions. Do not change any files.
3. Create the role yourself. Use your own administrator session, never the restricted one. An agent that can create roles can create more powerful ones. Create the role in the IAM console (IAM → Roles → Create role), or approve the drafts and have your administrator-session agent create it. Use a custom role, because the AWS-managed human-access roles under  /managed/  are protected in new projects.  Creating IAM roles ,  Managed policies for project organizations 
4. Give the agent a short session. A 15-minute session covers most deploys. Paste this in your administrator session:
Using my current session, assume the deployment role for 15 minutes. Save
only the temporary credentials to a new private folder that I will give to
the agent's environment. Do not print credential values. Do not copy my own
login or credential cache. Then confirm the saved session names the
deployment role.
A profile that points at your restricted role does not hide your other credentials. If the agent can read your broad login cache, it can use it. Give the agent an environment that holds only the restricted session, such as a separate container, user account, or machine. Also limit who can change the role's permissions or assume stronger roles.  Using an IAM role with the AWS CLI 
5. Test allowed and denied requests with the prompt in the testing section below.
6. Fix denials one at a time. The first real deploy will probably hit an AccessDenied error. Read it before you reach for  AdministratorAccess :
The last command was denied. Report the exact action, the resource, and the
policy that blocked it. Explain why the deploy needs it. Propose the smallest
change that fixes it, as a diff to the policy file. Do not apply it and do
not switch credentials.
Add one permission, rerun, and repeat. Ten small approvals beat one wildcard.
7. Tighten later. After a few successful deploys, ask the agent to compare the role's permissions with the actions in CloudTrail and propose removals for anything unused.

What access does an agent need to observe, build, or destroy?

These are planning categories, not built-in AWS permission modes.
Task category
Example request
Starting access design
Observe
Explain why this development function failed
Read its configuration and relevant logs
Build
Update this development function
Change the named function and its deployment artifacts; if assigning a runtime role, pass only the approved one
Destroy
Remove this completed experiment
A separately reviewed cleanup limited to its resources
A fourth category deserves extra scrutiny: changing authority. Creating identities, editing policies, issuing credentials, or passing powerful roles changes what future actions are possible. An agent meant to deploy an app should not quietly gain the ability to redesign its own access.
"Read-only" needs a scope too. Reading application data, secrets, or logs can expose sensitive information even when nothing changes. A build permission can also hurt: replacing function code changes behavior, and overwriting an object can lose data without calling a  Delete  API.
For a small development project, create, update, and delete access can be fine inside an agreed boundary. For production, let the interactive agent investigate, then put changes through a reviewed continuous integration and delivery (CI/CD) pipeline that has its own deployment role. Decide the boundary before you pick permissions.

What is the difference between a deployment role and a Lambda execution role?

The deployment role lets the agent update the function. The execution role is what Lambda assumes while the function runs. Keep them separate.
Suppose OrderApp runs on Lambda and reads report files from S3. That makes two jobs:
Identity
Job
Example permissions
 OrderApp-Agent-Dev 
Deploy the development app
Update the intended function, inspect its logs, pass its approved execution role when assigning it
 OrderApp-Lambda-Exec 
Run the application
Read the required report objects and write application logs
In this workflow, the agent does not assume the application role. When assigning that role to Lambda, it needs  iam:PassRole ; Lambda assumes the role at runtime. Updating only the function's code leaves the existing execution role in place and does not require  PassRole .  Lambda execution roles ,  UpdateFunctionCode 

Deployment authority and runtime authority have different jobs. Review both.
A safe  PassRole  grant names one role and one service. In plain words: the agent may pass  OrderApp-Lambda-Exec , and only to Lambda. Passing a powerful role to code the agent controls hands that code the role's authority, so treat a wildcard  PassRole  the way you treat a  // TODO: fix later  in production code.  How PassRole works 
In the new experience, IAM role manager can create execution roles automatically, and its templates can grant broad access. Open the role attached to your function and narrow it.  IAM role manager 
Ask your agent to audit this for you:
Look at my app's Lambda function. Name its execution role and list what that
role can do. Flag any wildcard actions, any wildcard resources, and any IAM
permissions. Suggest a narrower policy, but do not change anything.

How do you read an IAM policy in plain English?

This educational policy reads report objects from a fictional S3 bucket:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadOrderAppReports",
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::training-demo/reports/*"
}
]
}
Read it as: allow the attached identity to retrieve objects whose keys start with  reports/  in  training-demo .  Action  names the operation, and  Resource  names what it applies to. The trailing  *  matches the rest of the object key under that prefix. It does not mean every bucket. The policy grants no writes, deletes, or bucket listing.  S3 policy examples ,  S3 GetObject permissions 

One statement’s scope is not the same as an identity’s complete effective permissions.
IAM starts from implicit deny: a request fails unless a policy allows it. A matching explicit deny beats any allow. Adding a narrow allow next to an existing broad allow does not cancel the broad one, so review every policy that applies, including resource policies and organization guardrails.  Policies and permissions 
If a policy is unfamiliar, paste it to your agent:
Explain this IAM policy in plain English. List what it allows, what it does
not allow, and anything that looks broader than it needs to be.

How do you test an IAM permission boundary before trusting it?

For the S3 policy above, these are the results to expect when it is the only grant:
Request
Expected result
Reason
Read  reports/november.csv 
Allowed
Action and object match
Write  reports/november.csv 
Implicitly denied
No  s3:PutObject  grant
Read  private/notes.txt 
Implicitly denied
Object is outside the allowed prefix
Run the same kind of test against your agent role. Use the restricted session in a disposable development project:
You are running with the restricted deployment session. First report the
caller ARN. Then test these one at a time and report the result of each:
1. Read the configuration of the app's own function (should work).
2. Read the configuration of a different function (should be denied).
3. List IAM roles (should be denied).
Do not try to delete anything. Record the action, resource, and result for
each call, then continue after the expected denials in tests 2 and 3.
Stop if an expected denial succeeds or test 1 fails. Do not switch credentials.
A denial on calls 2 and 3 is the result you want. If either succeeds, the role is broader than you intended.
The  IAM policy simulator  can also check an action without calling the service. Its answer depends on the policies and context you give it, so confirm anything important in a disposable environment. Do not test a production deletion to see whether it is denied. If your policy is wrong, you will learn it in the most memorable way available.

What three security principles should guide agent access?

The  AWS Security Blog’s guidance on secure AI agent access  gives this workflow three checks: account for every granted permission, govern which roles agents use, and distinguish agent activity from human activity. Here is how I apply them to OrderApp.

1. Assume every granted permission may be used

Review what the session could do, including after a mistaken tool call or misleading instruction. Approve the impact of updating the development function and reading its logs; remove unrelated production access.
Include indirect authority. Lambda runs code with its execution role’s permissions. An agent that replaces OrderApp’s code can therefore cause that code to read report data when the function runs, even without permission to assume the execution role or pass a different one. Review  OrderApp-Lambda-Exec  before approving code-update access.  Lambda execution roles 

2. Decide who controls agent roles

AWS distinguishes two situations. With a prebuilt tool whose credentials you configure before launch (config-bound), select the scoped role in advance. With a custom agent or server whose credential-handling code you control (code-controlled), a trusted component can issue a narrower session for each operation. An OrderApp diagnostic operation could receive configuration-read and log-read permissions without code-update access.
Two IAM controls help:
  • A permissions boundary caps what a role’s identity-based policies can grant. An administrator can use one when delegating role management. It does not grant access by itself.  Permissions boundaries 
  • A session policy, supplied when calling  AssumeRole , limits that issued session’s identity-based permissions. It cannot add permissions missing from the role.  Session policies 
Keep changes to these controls outside the agent’s authority. Review resource-based policies too: grants directly to a role-session ARN can escape the implicit limits of a boundary or session policy. Neither control prevents use of separate, broader human credentials the agent can reach.  Policy evaluation with boundaries 
Teams already managing AWS Organizations can use  SCPs  at account or organizational-unit level to limit member-account permissions; SCPs grant nothing. New projects use  AWS-managed organization policies . Custom SCPs require  advanced features , which this exercise does not need.

3. Make agent activity distinguishable

Keep  OrderApp-Agent-Dev  separate from the human setup identity. Names alone do not prove who used the credentials; control the trust relationship and credential handoff. In a self-managed MCP server, trusted code can label sessions with tags such as  AccessType=AI . Policies can inspect  aws:PrincipalTag/AccessType ; the trust policy should control who can supply or override those tags.  Session tags 
For OrderApp, a policy matching trusted  AccessType=AI  tags could deny S3 deletion while a separately authorized human cleanup role retains it.
AWS managed MCP servers automatically add  aws:ViaAWSMCPService  and  aws:CalledViaAWSMCP  to downstream requests. These identify the MCP route and specific server, not every AI action. Self-managed servers do not automatically get those markers.  AWS MCP authorization 
A direct CLI call is another route. A deny applying only to MCP does not restrict that direct call, even if the same agent makes it. Use  MCP-specific policy controls  as an extra layer; keep the underlying role narrow across every route.

Put the workflow into practice

Before any change, paste this plan prompt:
Prepare the development deployment for review. Show the resources to
create, update, replace, or delete; any IAM or public-access changes;
expected costs; and the cleanup plan. Use the restricted session and do not
broaden its permissions. If access is denied, report the action, resource,
and policy context instead of switching to administrator credentials.
Wait for my approval before applying anything.
After an approved change, check what happened. CloudTrail Event history shows recent management events by Region. It does not include every data event, such as each object read. Compare the actor, action, target, and result with your plan.  CloudTrail Event history 
When you finish a test project, clean up:
List every resource we created for this exercise, including the deployment
role and its policies. Do not delete anything yet. Wait for me to approve
each deletion. Never delete resources that existed before this exercise.
Before your next agent-assisted deployment, write down one sentence:
This session may perform these actions on these resources in this environment.
Then check whether the credentials, policies, tools, and delegated roles make that sentence true. If they disagree, fix the role, not the sentence.
And the next time an AccessDenied error shows up, read it before you attach  AdministratorAccess . I say this as someone who has attached it.

Frequently asked questions

Does installing the Agent Toolkit for AWS reduce my agent's permissions?

No. The toolkit gives your agent AWS tools, documentation, and task guidance. Permissions come from the credentials the agent uses.

Can I use the root user in a new AWS project?

No. Root-user sign-in is not available in project accounts, even after you activate advanced features. Create a custom IAM role for programmatic agent access instead.

Can I do this on the free plan?

Yes. Custom IAM roles and users for programmatic access are available without a paid upgrade or advanced features. You cannot write your own organization-level guardrails, because AWS manages those until you activate advanced features.

When does a Lambda deployment need  iam:PassRole ?

When the agent assigns an execution role to Lambda, it needs permission to pass that role. Scope  PassRole  to one named role and to  lambda.amazonaws.com . A code-only update using  UpdateFunctionCode , as shown on the cover, does not pass a new role and does not require this permission.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article