/localstack:localstack-iamfrom localstack
Analyzes and enforces IAM policies in LocalStack. Detects permission violations, auto-generates least-privilege policies, and tests policies locally before deploying to AWS.
Ships in localstack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Analyze IAM policies, detect permission violations, and automatically generate least-privilege policies based on actual usage.
lstk CLI, authenticated with a LocalStack account (lstk login, or LOCALSTACK_AUTH_TOKEN in CI) — see the localstack skillSet the starting mode in an environment profile in config.toml, then lstk start (or lstk restart):
[[containers]]
type = "aws"
env = ["iam"]
[env.iam]
ENFORCE_IAM = "1"
IAM_SOFT_MODE = "1" # remove for full enforcement
IAM_SOFT_MODE only takes effect together with ENFORCE_IAM = "1".
To change the mode on a running emulator without touching config, use the runtime switch.
| Mode | Profile keys at start | Runtime state | Behavior |
|---|---|---|---|
| Disabled (default) | unset, or ENFORCE_IAM = "0" | DISABLED | No IAM checks |
| Soft | ENFORCE_IAM = "1", IAM_SOFT_MODE = "1" | SOFT_MODE | Logs violations, allows requests |
| Enforced | ENFORCE_IAM = "1" | ENFORCED | Denies unauthorized requests |
| Engine only | none; set at runtime | ENGINE_ONLY | Evaluates policies and records denials in App Inspector, but neither blocks nor logs them |
Enabling App Inspector moves the mode from DISABLED to ENGINE_ONLY, so denials are recorded without enforcement. Never switch to ENFORCED just to see denials; it can break a workload that works.
The IAM config endpoint reads and changes the mode on a running emulator, so you can flip enforcement between test runs instead of restarting:
# Current mode
curl -s localhost:4566/_aws/iam/config | jq .state
# Change it: ENFORCED, SOFT_MODE, ENGINE_ONLY, or DISABLED
curl -s -X POST localhost:4566/_aws/iam/config \
-H 'Content-Type: application/json' -d '{"state":"SOFT_MODE"}'
The runtime change lasts until the emulator restarts; use the start-time setting above for a default.
lstk aws proxies the host aws CLI with the LocalStack endpoint, credentials, and region pre-configured.
# Create user
lstk aws iam create-user --user-name dev-user
# Create access key
lstk aws iam create-access-key --user-name dev-user
# Attach policy
lstk aws iam attach-user-policy \
--user-name dev-user \
--policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
# Create policy from JSON file
lstk aws iam create-policy \
--policy-name my-custom-policy \
--policy-document file://policy.json
// Example policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
Start with App Inspector for any permission error. LocalStack records each denied request with the policies that decided it, including another account's policies that you cannot read, and a suggested fix. It also derives least-privilege policies from a run. See the "Explain IAM denials" and "Derive least-privilege policies" sections of the localstack-app-inspector skill.
Use the Policy Stream below for what App Inspector does not record, such as requests to STS and IAM (for example a trust policy failing sts:AssumeRole), and when the license or image has no App Inspector IAM events.
GET /_aws/iam/policies/stream streams one JSON line for every request IAM evaluates, while the connection stays open. It needs IAM evaluation on (SOFT_MODE, ENFORCED, or ENGINE_ONLY) and a license that includes the IAM Policy Stream.
Open the stream before running the workload; it shows only requests made while it is connected:
curl -sN localhost:4566/_aws/iam/policies/stream > iam-stream.jsonl &
# run the workload, then stop the stream
kill %1
Each line holds:
request: service, operation, parameters, id, internal, and allowed, which is false when IAM denies the request, even in a mode that lets it throughresource: the principal ARN for an identity policy, or the resource ARN for a resource policy, such as a Lambda's resource policy for a service principalpolicy_type: identity or resourcepolicy_document: the least-privilege policy for resource that allows every request seen so far for it, not only this oneViolations are the lines where request.allowed is false:
jq -c 'select(.request.allowed == false)
| {principal: .resource, type: .policy_type, call: "\(.request.service).\(.request.operation)",
allow: [.policy_document.Statement[] | {Action, Resource}]}' iam-stream.jsonl
The stream also carries every allowed request, including the root user's own calls, so always filter. A cross-account request produces two lines: an identity policy for the caller and a resource policy for the target. Add ?include_evaluation_failures=1 to also stream requests whose evaluation raised an error; those lines carry evaluation_failed: true, error_type, and error_message instead of a policy, and LocalStack let them through unchecked.
SOFT_MODE or ENGINE_ONLY, so the run completes instead of stopping at the first denial.curl -s -X DELETE localhost:4566/_aws/iam/policies/summary, then exercise the full workload once.curl -s localhost:4566/_aws/iam/policies/summary | jq: one entry per resource, with its policy_type and merged policy_document. From a saved stream instead, take the last line for each resource, since every line holds the merged document so far.Principal belong in a resource policy or a role's trust policy.ENFORCED, rerun the workload, and repeat until the stream shows no "allowed": false lines.The policies cover only the requests observed, and their Sid values are generated. Review them for wildcards before use.
# Test if action would be allowed
lstk aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::000000000000:user/dev-user \
--action-names s3:GetObject \
--resource-arns arn:aws:s3:::my-bucket/file.txt
# Check policy syntax
lstk aws accessanalyzer validate-policy \
--policy-document file://policy.json \
--policy-type IDENTITY_POLICY
/_aws/iam/config between runs instead of restartinglstk save so you can restore it after experimentsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub localstack/skills --plugin localstack12 skills in this plugin
/localstack-app-inspectorTrace requests through LocalStack with App Inspector. Use when users want to see how a request flowed across AWS services, inspect traces, spans, events, or payloads, debug event-driven or service-to-service flows, or explain an IAM denial, get LocalStack's suggested policy fix, or derive least-privilege policies from a run./localstack-replicatorCopy resources from a real AWS account into LocalStack with AWS Replicator. Use when a local stack depends on shared AWS resources that already exist (VPCs, SSM parameters, IAM roles, ECR repositories, secrets) and the user wants them replicated locally instead of re-creating them./localstack-azureRun the LocalStack Azure emulator and drive it with the Azure CLI. Use when users want to start LocalStack for Azure, run az commands locally (resource groups, storage, blobs, Bicep/ARM deployments), or set up lstk az./localstack-chaosInject faults and network latency into LocalStack to test resilience. Use when users want chaos engineering, to simulate AWS outages or throttling, return errors from specific services or operations, add latency, or verify retry and fallback logic./localstack-deployDeploy infrastructure to LocalStack using IaC tools. Use when users want to deploy Terraform, CDK, CloudFormation, SAM, or Pulumi to LocalStack, check which resources LocalStack supports before deploying, or need help with lstk deploy, the lstk proxy commands (lstk terraform, lstk cdk, lstk sam, lstk aws), or the pulumilocal wrapper./localstack-infra-testDeploy an IaC project to LocalStack, validate every declared resource against live state, then write and run integration tests. Use when users want to test or validate their infrastructure, check that a Terraform, CDK, SAM, or CloudFormation stack actually works, or generate integration tests for it.Other plugins' skills for the same job