Skip to content

Back to the catalog

IAM Policy Autopilot
github.comrepo

IAM Policy Autopilot

IAM Policy Autopilot is an AWS Labs open-source CLI/MCP server that statically analyzes application source code (Python, Go, TypeScript, JavaScript, Java) or a Terraform plan JSON to generate baseline least-privilege IAM identity-based policies, and can also parse AccessDenied error messages to suggest policy fixes. It integrates with AI coding assistants (Kiro, Claude Desktop, etc.) via MCP so assistants can auto-generate scoped IAM permissions instead of overly broad ones, with a --service-hints flag to reduce false-positive permission inclusion.

TL;DR AWS Labs MCP/CLI tool that statically analyzes app code or Terraform plans to auto-generate least-privilege IAM policies.
Document

What it is

IAM Policy Autopilot, an AWS Labs tool for generating baseline identity-based IAM policies from static code analysis. The summary covers the core; this document carries the install commands and the security-relevant gotchas the summary does not.

What to do

Run directly without install via uvx, or install with pip or a system script:

pip install iam-policy-autopilot
curl -sSL https://github.com/awslabs/iam-policy-autopilot/raw/refs/heads/main/install.sh | sudo sh

The curl script installs to /usr/local/bin/iam-policy-autopilot. Note it runs a piped remote script under sudo — inspect it first. AWS credentials (via AWS CLI) are required for applying policy fixes and uploading policies for AccessDenied debugging.

Scope down false positives with service hints:

iam-policy-autopilot generate-policies ./src/app.py --service-hints s3 iam organizations --pretty

Caveats

Two behaviors matter for anyone treating the output as a security artifact:

  • Method-name collisions over-grant. Static analysis matches SDK method names, not services. A listAccounts() call generates permissions for both AWS Organizations and Amazon Chime. --service-hints narrows this but the page states the final policy may still pull in actions from unlisted services when operations require them (e.g., KMS actions for S3 encryption). Hints are CLI-only; under the MCP integration the assistant is expected to supply them from code context.
  • The coding assistant, not Autopilot, may alter the policy. When used via MCP, the AI assistant receives the policy and can modify it when producing IaC — adding resource ARNs or KMS key IDs from its own interpretation of your code. These changes do not come from the deterministic analysis and must be reviewed independently.

Additional limits the page states: runtime-determined resources aren't predicted (s3.getObject(bucketName) with a dynamic bucket yields no bucket scoping); native .tf files are unsupported — only Terraform plan JSON; and beyond the resource-based/SCP/RCP exclusions, permission boundaries are also out of scope.

Technologies named here

Techniques named here

  • Deterministic static code analysis for IAM policy generation
  • AccessDenied error analysis and remediation
  • Service-hint scoping