aws-iam
aws/agent-toolkit-for-aws
Verified corrections for IAM edge cases, policy evaluation quirks, and common agent mistakes.
What is aws-iam?
This skill contains verified corrections for IAM behaviors that AI agents frequently misunderstand, including policy evaluation edge cases, trust policy gotchas, STS session limits, Organizations quirks, and SAML/MFA specifics. Use it alongside AWS documentation when working with IAM roles, policies, STS, or Organizations. Do NOT use for non-IAM authorization like Cognito or app-level RBAC.
- Clarifies policy evaluation edge cases (ForAllValues with empty keys, resource-based policy bypass of permissions boundaries)
- Documents STS restrictions (GetSessionToken limits, cross-account AssumeRole region requirements, role chaining max 1-hour sessions)
- Explains Organizations quirks (suspended account removal, policy delegation via PutResourcePolicy, policy type filters)
- Covers privilege escalation vectors (8 direct IAM policy manipulation actions, iam:PassRole scope risks)
- Provides SDK-specific corrections (Boto3 AccessKey methods, DuplicatePolicyAttachmentException, instance profile waiters)
- Details SAML, MFA, and service-specific role configurations (Redshift Serverless dual principals, OIDC thumbprint changes)
How to install aws-iam
npx skills add https://github.com/aws/agent-toolkit-for-aws --skill aws-iamHow to use aws-iam
- 1.Install the skill via npx skills add
- 2.Reference specific edge cases when answering IAM questions (policy evaluation, STS limits, Organizations behavior)
- 3.Verify claims against official AWS documentation rather than relying on pre-training
- 4.Use the provided policy examples (e.g., ForAllValues + Null condition pattern) as templates for correct configurations
Use cases
- Debugging why a policy with ForAllValues:StringEquals on aws:TagKeys allows untagged resources (vacuous truth issue)
- Securing iam:PassRole permissions to prevent privilege escalation to Administrator roles
- Fixing Redshift Serverless COPY failures caused by missing redshift.amazonaws.com in trust policy
- Understanding why AcceptHandshake/DeclineHandshake appear only in acting account CloudTrail, not management account
- Resolving Organizations policy attachment errors (DuplicatePolicyAttachmentException vs. PolicyAlreadyAttachedException)
- IAM architects and security engineers designing role and policy structures
- DevOps engineers troubleshooting cross-account access and STS session issues
- Cloud security teams auditing privilege escalation risks and policy evaluation logic
- AI agents and developers building IAM automation that needs to avoid common pitfalls
aws-iam FAQ
Use this skill to quickly identify and correct common agent mistakes and edge cases. Always verify specific claims (limits, quotas, API names) against official AWS documentation. Trust official documentation over memory when they conflict.
No. This skill is for IAM roles, policies, STS, and Organizations only. Do NOT use it for Cognito user-pool policies or application-level role-based access control.
ForAllValues:StringEquals with an empty or missing key evaluates to true by default. To require the key to be present and non-null, add a Null condition on the same context key in the same statement.
Scope the Resource element to specific role ARNs or IAM paths instead of using Resource: "*". Optionally constrain further with iam:PassedToService or iam:AssociatedResourceArn conditions.
The trust policy must include BOTH redshift-serverless.amazonaws.com AND redshift.amazonaws.com as service principals. Omitting the redshift.amazonaws.com principal causes this error.
Full instructions (SKILL.md)
Source of truth, from aws/agent-toolkit-for-aws.
name: aws-iam
description: "Verified corrections for IAM behaviors that AI agents frequently get
\ wrong \u2014 policy evaluation edge cases, trust policy gotchas, STS session limits,
\ Organizations quirks, and SAML/MFA specifics. Use alongside documentation when
\ working with IAM roles, policies, STS, or Organizations. Do NOT use for non-IAM
\ authorization like Cognito user-pool policies or app-level RBAC."
version: 1
AWS IAM — Common Pitfalls
About This Skill
This skill contains verified corrections for things that AI agents frequently get wrong about IAM. It is not a comprehensive IAM guide — for full IAM guidance, search AWS documentation.
When answering IAM questions, verify specific claims (limits, quotas, exact API names, edge-case behaviors) against official AWS documentation rather than relying on pre-training. Prefer fetching known documentation URLs over broad searches. Trust official documentation over memory when they conflict.
Verified Edge Cases
CloudTrail:
- AcceptHandshake/DeclineHandshake logged in ACTING account ONLY, not management account. Organization trail required for centralization.
- ConsoleLogin region varies by endpoint/cookies, NOT always us-east-1.
?region=forces specific region.
STS:
- GetSessionToken restrictions: (1) No IAM APIs unless MFA included (2) No STS except AssumeRole and GetCallerIdentity.
- Cross-account AssumeRole to opt-in region: TARGET account must enable region, not calling account.
- Role chaining: max 1-hour session.
Organizations:
- Suspended/closed accounts CANNOT be removed until permanently closed (~90 days). Remove FIRST, then close.
- Policy management delegation: use PutResourcePolicy, NOT register-delegated-administrator.
- AI opt-out policies: management account required by default.
- Organizations policy types for ListPolicies filter: SERVICE_CONTROL_POLICY, TAG_POLICY, BACKUP_POLICY, AISERVICES_OPT_OUT_POLICY, CHATBOT_POLICY, DECLARATIVE_POLICY_EC2, RESOURCE_CONTROL_POLICY.
SDK Specifics:
- Organizations:
DuplicatePolicyAttachmentException(not PolicyAlreadyAttachedException). - Boto3 IAM AccessKey: methods are
activate(),deactivate(),delete()— NOupdate(). - Instance profiles: waiter +
time.sleep(10)pattern. - Managed policy max versions: 5.
SAML:
- Encrypted assertions URL:
https://region-code.signin.aws.amazon.com/saml/acs/IdP-ID. - Private key from IdP uploaded to IAM in .pem format.
Policy Evaluation:
- ForAllValues with empty/missing key: evaluates to true (vacuous truth). To avoid that, use a
Nullcondition in addition to theForAllValueson the same context key to require that key to be present and non-null. For example, when evaluating theaws:TagKeyscontext key:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": {
"aws:TagKeys": ["Alpha", "Beta"]
},
"Null": {
"aws:TagKeys": "false"
}
}
}
}
- Resource-based policies granting to IAM user ARN bypass permissions boundaries in same account.
- 8 privilege escalation actions via direct IAM policy manipulation: PutGroupPolicy, PutRolePolicy, PutUserPolicy, CreatePolicy, CreatePolicyVersion, AttachGroupPolicy, AttachRolePolicy, AttachUserPolicy.
iam:PassRolewithResource: "*"+ create/update on a compute service (EC2RunInstances, LambdaCreateFunction/UpdateFunctionConfiguration, ECSRegisterTaskDefinition, Glue, SageMaker, CloudFormation, etc.) = privilege escalation to any passable role in the account, including Administrator. ScopeResourceto specific role ARNs or an IAM path; optionally constrain withiam:PassedToService/iam:AssociatedResourceArn. See IAM User Guide — Grant a user permissions to pass a role.
MFA:
- Unassigned virtual MFA devices auto-deleted when adding new ones.
- MFA resync-only policy NotAction needs exactly: iam:ListMFADevices, iam:ListVirtualMFADevices, iam:ResyncMFADevice.
SigV4:
- IncompleteSignatureException includes SHA-256 hash of Authorization header for transit modification diagnosis.
Service-Specific Roles:
- Redshift Serverless trust policy: include BOTH
redshift-serverless.amazonaws.comANDredshift.amazonaws.comas service principals (per AWS docs; omitting serverless causesNot authorized to get credentials of roleon COPY). - IAM OIDC providers: thumbprints no longer required for most providers (AWS verifies via trusted CAs since 2022).
Policy Summary Display:
- Single statement with multi-service wildcard actions (e.g.
codebuild:*,codecommit:*) + service-specific resource ARNs: each resource appears ONLY under its matching service's summary (CodeBuild ARN under CodeBuild, etc.). A resource whose service prefix matches NO action in the statement is the only case where it appears in all action summaries ("mismatched resource").
Related skills
More from aws/agent-toolkit-for-aws and the wider catalog.

aws-messaging-and-streaming
Choose and implement AWS messaging (SQS, SNS, EventBridge, MQ) and streaming (Kinesis, Firehose, Flink, MSK) services.

aws-observability
Build, configure, and optimize AWS observability across CloudWatch, X-Ray, CloudTrail, and ADOT.

aws-sdk-js-v3-usage
AWS SDK for JavaScript v3 development patterns and best practices.

aws-sdk-python-usage
AWS SDK for Python (boto3/botocore) development patterns and best practices.

aws-sdk-swift-usage
AWS SDK for Swift patterns and async client usage for S3, DynamoDB, CloudWatch, and other AWS services.

aws-serverless
Build, deploy, debug, and optimize serverless applications on AWS Lambda, API Gateway, Step Functions, and EventBridge.