PluginBench
Skill
Official
Pass
Audit score 90

aws-iam

aws/agent-toolkit-for-aws

Verified IAM corrections and workflows for role management, policy generation, and edge-case handling.

What is aws-iam?

Provides corrections for common IAM mistakes—policy evaluation edge cases, trust policy gotchas, STS session limits, Organizations quirks, and SAML/MFA specifics. Use this when creating IAM roles, writing policies, generating policies from application source code or Terraform plans, working with STS/Organizations, or setting up service roles for AWS services.

  • Corrects verified IAM edge cases: CloudTrail logging regions, STS restrictions, Organizations account removal, SAML encrypted assertions, and policy evaluation with ForAllValues/Null conditions
  • Provides structured workflows for IAM role management including service roles, execution roles, trust policies, and confused deputy protection
  • Generates baseline IAM policies from application source code or Terraform plan JSON using iam-policy-autopilot
  • Covers privilege escalation prevention: iam:PassRole scoping, resource-based policy bypasses, and 8 direct policy manipulation actions
  • Explains service-specific role requirements: Redshift Serverless dual principals, Lambda/ECS/Glue/CloudTrail service role creation, and aws:SourceAccount/aws:SourceArn trust conditions
  • Clarifies MFA, SigV4, Organizations policy delegation, and managed policy version limits

How to install aws-iam

npx skills add https://github.com/aws/agent-toolkit-for-aws --skill aws-iam
Claude Code
Cursor
Windsurf
Cline

How to use aws-iam

  1. 1.When creating or updating IAM roles, read the role management reference for trust policy patterns and service-specific requirements
  2. 2.When generating policies from application source code or Terraform plan JSON, read the policy generation reference and use iam-policy-autopilot
  3. 3.For STS, Organizations, or policy evaluation questions, consult the verified edge cases section for correct behavior and limits
  4. 4.Verify specific IAM limits, quotas, and API names against official AWS documentation rather than relying on pre-training
  5. 5.Use AWS MCP server, AWS CLI, or SDK as available for actual AWS operations

Use cases

Good for
  • Creating IAM roles with proper trust policies and confused deputy protection for AWS services like Lambda, ECS, Glue, or CloudTrail
  • Generating least-privilege IAM policies from application source code or Terraform plans instead of manual policy construction
  • Debugging STS cross-account AssumeRole failures, session token restrictions, or role chaining issues
  • Writing bucket policies with VPC endpoint restrictions and deny patterns
  • Implementing Organizations policy management and handling suspended/closed account removal workflows
Who it's for
  • AWS infrastructure engineers provisioning roles and policies
  • DevOps/platform teams generating policies from application code or IaC
  • Security engineers reviewing IAM configurations for privilege escalation risks
  • Developers using AWS SDKs (Boto3, etc.) for IAM operations
  • Teams managing multi-account AWS Organizations

aws-iam FAQ

When should I use iam-policy-autopilot vs. manual policy construction?

Use iam-policy-autopilot whenever the user provides application source code (any language) or a Terraform plan JSON file. Manual policy construction is error-prone; the autopilot uses the programmatic service authorization reference for accurate action-to-operation mappings.

How do I prevent privilege escalation via iam:PassRole?

Scope the Resource in iam:PassRole to specific role ARNs or IAM paths instead of using Resource: "*". Optionally add conditions like iam:PassedToService or iam:AssociatedResourceArn to further restrict which services can use the role.

What's the difference between ForAllValues and ForAllValues with Null conditions?

ForAllValues alone evaluates to true if the key is missing or empty (vacuous truth). To require the key to be present and non-null, add a Null condition on the same context key set to "false" in the same statement.

Why does my Redshift Serverless COPY fail with 'Not authorized to get credentials'?

Redshift Serverless trust policies must include BOTH redshift-serverless.amazonaws.com AND redshift.amazonaws.com as service principals. Omitting the serverless principal causes credential access failures.

What are the STS GetSessionToken restrictions?

GetSessionToken sessions cannot call any IAM APIs unless MFA is included, and can only call STS AssumeRole and GetCallerIdentity. Cross-account AssumeRole to opt-in regions requires the TARGET account to enable the region, not the calling account.

Full instructions (SKILL.md)

Source of truth, from aws/agent-toolkit-for-aws.


name: aws-iam description: > Provides verified corrections for IAM behaviors that AI agents frequently get wrong — policy evaluation edge cases, trust policy gotchas, STS session limits, Organizations quirks, and SAML/MFA specifics. Also provides structured workflows for IAM role management and baseline policy generation from application source code or a Terraform plan JSON. Covers condition operator safety (ForAnyValue/ForAllValues with Null checks), bucket policy deny patterns (VPC endpoint restrictions, org paths), confused deputy protection, and service role creation for AWS services (Glue, CloudTrail, Lambda, ECS, etc.) with aws:SourceAccount/aws:SourceArn trust conditions. Applies when creating IAM roles, writing IAM or bucket policies, generating policies from application source code or a Terraform plan JSON, working with STS, Organizations, or condition operators, or any task needing a service or execution role. Does not cover non-IAM authorization like Cognito user-pool policies or app-level RBAC. metadata: version: "2"

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.

Common Workflows

Use the best available tool for AWS operations — the AWS MCP server is recommended but not required; AWS CLI or SDK may be used as alternatives. Read reference files only when the conversation requires deeper detail.

  • Read references/aws-iam-role-management.md if the user needs to create, scope, or maintain IAM roles when provisioning or updating AWS resources. Covers service roles, execution roles, trust policies, confused deputy protection, and permission hygiene.

  • Read references/aws-iam-policy-generation.md if the user needs to generate IAM policies, determine required IAM actions for API calls, or understand action-to-operation mappings. CRITICAL: If the user provides application source code (in any language) or a Terraform plan JSON file (terraform show -json output), you MUST read this reference — it mandates using iam-policy-autopilot instead of manual policy construction. Uses the programmatic service authorization reference for accurate mappings.

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: fetch the current list via aws organizations list-available-policy-types or the Organizations API reference.

SDK Specifics:

  • Organizations: DuplicatePolicyAttachmentException (not PolicyAlreadyAttachedException).
  • Boto3 IAM AccessKey: methods are activate(), deactivate(), delete() — NO update().
  • 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 Null condition in addition to the ForAllValues on the same context key to require that key to be present and non-null. For example, when evaluating the aws:TagKeys context 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:PassRole with Resource: "*" + create/update on a compute service (EC2 RunInstances, Lambda CreateFunction/UpdateFunctionConfiguration, ECS RegisterTaskDefinition, Glue, SageMaker, CloudFormation, etc.) = privilege escalation to any passable role in the account, including Administrator. Scope Resource to specific role ARNs or an IAM path; optionally constrain with iam: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.com AND redshift.amazonaws.com as service principals (per AWS docs; omitting serverless causes Not authorized to get credentials of role on COPY).
  • IAM OIDC providers: thumbprints are not required for most providers (AWS verifies via trusted CAs).

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").