skills/iam-policy-analyzer/SKILL.md
Analyze and enforce IAM policies in LocalStack. Use when users want to enable IAM enforcement, detect permission violations, auto-generate least-privilege policies, or test IAM policies locally before deploying to AWS.
npx skillsauth add localstack/skills localstack-iamInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze IAM policies, detect permission violations, and automatically generate least-privilege policies based on actual usage.
IAM enforcement requires LocalStack Pro:
export LOCALSTACK_AUTH_TOKEN=<your-token>
# Soft mode - logs violations but allows requests
ENFORCE_IAM=soft localstack start -d
# Enforced mode - denies unauthorized requests
ENFORCE_IAM=1 localstack start -d
| Mode | Behavior |
|------|----------|
| Disabled (default) | No IAM checks |
| soft | Logs violations, allows requests |
| 1 / enforced | Full enforcement, denies unauthorized |
# Create user
awslocal iam create-user --user-name dev-user
# Create access key
awslocal iam create-access-key --user-name dev-user
# Attach policy
awslocal iam attach-user-policy \
--user-name dev-user \
--policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
# Create policy from JSON file
awslocal 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/*"
}
]
}
# View IAM-related log entries
localstack logs | grep -i "access denied"
localstack logs | grep -i "iam"
Based on access patterns observed in soft mode, create least-privilege policies:
ENFORCE_IAM=soft# Test if action would be allowed
awslocal 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
awslocal accessanalyzer validate-policy \
--policy-document file://policy.json \
--policy-type IDENTITY_POLICY
devops
Manage LocalStack state and snapshots. Use when users want to save, load, export, or import LocalStack state, work with Cloud Pods, create local snapshots, or enable persistence across restarts.
development
Analyze LocalStack logs and debug issues. Use when users need to view LocalStack logs, debug AWS API errors, troubleshoot Lambda functions, identify error patterns, or enable debug mode.
testing
Manage LocalStack container lifecycle. Use when users need to start, stop, restart, or check status of LocalStack, configure LocalStack environment variables, or troubleshoot LocalStack container issues.
tools
Manage LocalStack Extensions. Use when users want to install, uninstall, list, or configure LocalStack extensions, or develop custom extensions to extend LocalStack functionality.