Generated banner for AWS Iam
Generated logo for AWS Iam

AWS Iam

AWSOfficialPublished by AWS

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • Low risk

From the author

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.
— the description by AWS

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to AWS IAM management, focusing on correcting common AI pitfalls regarding policy evaluation, trust policies, and service-specific role configurations. It mandates the use of automated tools for policy generation when source code or Terraform plans are available, ensuring deterministic and secure outcomes. It covers critical edge cases including STS session limits, Organizations quirks, and condition operator safety, while providing clear guidelines for creating scoped service and execution roles with proper confused deputy protections.

What it does

  • Provides verified corrections for common AI-generated IAM policy errors.
  • Mandates automated policy generation for application source code and Terraform plan JSON files.
  • Defines structured workflows for creating service and execution roles with confused deputy protection.
  • Offers guidance on complex IAM topics like condition operators, trust policies, and Organizations.
  • Supplies specific patterns for handling STS, SAML, MFA, and service-specific role requirements.
  • Ensures adherence to security best practices by prioritizing official documentation over pre-training.

When to use it

  • When creating or updating IAM roles for AWS services.
  • When generating IAM policies from application source code or Terraform plan JSON files.
  • When troubleshooting IAM policy evaluation, trust policy issues, or condition operator logic.
  • When configuring cross-account access, STS sessions, or AWS Organizations policies.
  • When implementing security-hardened service roles with source account and ARN restrictions.

Advantages

  • Reduces security risks by enforcing confused deputy protection and scoped permissions.
  • Eliminates manual policy construction errors through automated tool integration.
  • Provides reliable, verified solutions for known IAM edge cases and pitfalls.
  • Standardizes role management workflows across different AWS services.
  • Ensures policy generation is reproducible and based on deterministic analysis.

Usage examples

“Create an IAM execution role for a Lambda function that needs to read from a specific S3 bucket.”
The agent will identify the Lambda service principal, construct a trust policy with appropriate source account conditions, and generate a scoped permissions policy for the S3 bucket.
“Generate an IAM policy based on this Terraform plan JSON.”
The agent will provide the exact uvx iam-policy-autopilot command to generate the policy, ensuring the output is derived from deterministic analysis of the plan.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/aws/aws-iam/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip aws-iam.zip -d .agents/skills

Documentation by AWS

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"
          }
        }
      }
    }
  • aws:TagKeys values are case-sensitive, but the tag key in aws:PrincipalTag/<key>, aws:ResourceTag/<key>, and aws:RequestTag/<key> is not. The Allow allowlist above is unaffected (a re-cased key is simply not in the list), but a Deny that protects a tag key with ForAnyValue:StringEquals on aws:TagKeys is bypassed by a re-cased key (PROTECTED-TAG) — use ForAnyValue:StringEqualsIgnoreCase. See references/common-pitfalls.md.

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

Files

references/service-authorization.md

Service Authorization Reference

Endpoint

URL pattern: https://servicereference.us-east-1.amazonaws.com/v1/<service>/<service>.json

These files are large (tens to hundreds of KB). Always extract only what you need.

Query Patterns

Use the service_reference_query tool when available. If unavailable, use curl piped to jq.

Pattern 1: Authorized actions for an operation (most common)
{ "service": "s3", "operation": "CopyObject" }

Returns the actions needed to authorize the operation, including cross-service actions.

Pattern 2: Verify an action name exists
{ "service": "s3", "action": "GetObject" }

Use when building conditions or when an operation has no Operations entry.

Pattern 3: Look up a resource ARN format
{ "service": "s3", "resource": "bucket" }
Pattern 4: Check a condition key's type
{ "service": "s3", "condition_key": "aws:TagKeys" }

Essential before using ForAnyValue/ForAllValues — these operators MUST only be used with array-typed keys (ArrayOfString, ArrayOfARN, etc.).

Pattern 5: List all operations or actions for a service
{ "service": "dynamodb", "list": "operations" }

If the operation name is not found, the tool returns the list of available operations.

Reference Structure

Each service reference JSON contains four top-level arrays:

  • Actions — IAM actions with resource types and condition keys

  • Operations — API operations mapped to authorized actions (available for most services; absent for a few)

  • Resources — Resource type definitions with ARN formats

  • ConditionKeys — Condition key definitions with types (String, ArrayOfString, Bool, etc.)

Each Operation entry contains:

  • Name — The API operation name (e.g., CreateFunction)

  • AuthorizedActions — IAM actions required, each with Name, Service (may differ from the queried service for cross-service actions), and optional Context

CLI Fallback

When the service_reference_query tool is unavailable, use curl and jq:

# Get authorized actions for an operation
curl -s "https://servicereference.us-east-1.amazonaws.com/v1/lambda/lambda.json" | \
  jq '.Operations[] | select(.Name == "CreateFunction")'

# Verify an action exists
curl -s "https://servicereference.us-east-1.amazonaws.com/v1/s3/s3.json" | \
  jq '.Actions[] | select(.Name == "GetObject")'

# Look up resource ARN format
curl -s "https://servicereference.us-east-1.amazonaws.com/v1/s3/s3.json" | \
  jq '.Resources[] | select(.Name == "bucket")'

# Check condition key type
curl -s "https://servicereference.us-east-1.amazonaws.com/v1/s3/s3.json" | \
  jq '.ConditionKeys[] | select(.Name == "aws:TagKeys")'

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an MCP server

Security

What our scanner noticed· Low risk

  • Phrasing that asks for actions without confirmation
  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
AWS
Publisher
AWS (Official)
Source
aws/agent-toolkit-for-aws · skills/core-skills/aws-iam · commit 0a218f8
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
aws/agent-toolkit-for-aws

AutoGineer is not affiliated with or endorsed by AWS or AWS.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-iam.zip