AWS Identity and Access Management for users, roles, policies, and permissions. Use when creating IAM policies, configuring cross-account access, setting up service roles, troubleshooting permission errors, or managing access control.
Install
mkdir -p .claude/skills/iam && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4131" && unzip -o skill.zip -d .claude/skills/iam && rm skill.zipInstalls to .claude/skills/iam
About this skill
AWS IAM
AWS Identity and Access Management (IAM) enables secure access control to AWS services and resources. IAM is foundational to AWS security—every AWS API call is authenticated and authorized through IAM.
Table of Contents
Core Concepts
Principals
Entities that can make requests to AWS: IAM users, roles, federated users, and applications.
Policies
JSON documents defining permissions. Types:
- Identity-based: Attached to users, groups, or roles
- Resource-based: Attached to resources (S3 buckets, SQS queues)
- Permission boundaries: Maximum permissions an identity can have
- Service control policies (SCPs): Organization-wide limits
Roles
Identities with permissions that can be assumed by trusted entities. No permanent credentials—uses temporary security tokens.
Trust Relationships
Define which principals can assume a role. Configured via the role's trust policy.
Common Patterns
Create a Service Role for Lambda
AWS CLI:
# Create the trust policy
cat > trust-policy.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "lambda.amazonaws.com" },
"Action": "sts:AssumeRole"
}
]
}
EOF
# Create the role
aws iam create-role \
--role-name MyLambdaRole \
--assume-role-policy-document file://trust-policy.json
# Attach a managed policy
aws iam attach-role-policy \
--role-name MyLambdaRole \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
boto3:
import boto3
import json
iam = boto3.client('iam')
trust_policy = {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {"Service": "lambda.amazonaws.com"},
"Action": "sts:AssumeRole"
}
]
}
# Create role
iam.create_role(
RoleName='MyLambdaRole',
AssumeRolePolicyDocument=json.dumps(trust_policy)
)
# Attach managed policy
iam.attach_role_policy(
RoleName='MyLambdaRole',
PolicyArn='arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
)
Create Custom Policy with Least Privilege
cat > policy.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Query"
],
"Resource": "arn:aws:dynamodb:us-east-1:123456789012:table/MyTable"
}
]
}
EOF
aws iam create-policy \
--policy-name MyDynamoDBPolicy \
--policy-document file://policy.json
Cross-Account Role Assumption
# In Account B (trusted account), create role with trust for Account A
cat > cross-account-trust.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::111111111111:root" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": { "sts:ExternalId": "unique-external-id" }
}
}
]
}
EOF
# From Account A, assume the role
aws sts assume-role \
--role-arn arn:aws:iam::222222222222:role/CrossAccountRole \
--role-session-name MySession \
--external-id unique-external-id
CLI Reference
Essential Commands
| Command | Description |
|---|---|
aws iam create-role | Create a new IAM role |
aws iam create-policy | Create a customer managed policy |
aws iam attach-role-policy | Attach a managed policy to a role |
aws iam put-role-policy | Add an inline policy to a role |
aws iam get-role | Get role details |
aws iam list-roles | List all roles |
aws iam simulate-principal-policy | Test policy permissions |
aws sts assume-role | Assume a role and get temporary credentials |
aws sts get-caller-identity | Get current identity |
Useful Flags
--query: Filter output with JMESPath--output table: Human-readable output--no-cli-pager: Disable pager for scripting
Best Practices
Security
- Never use root account for daily tasks
- Enable MFA for all human users
- Use roles instead of long-term access keys
- Apply least privilege — grant only required permissions
- Use conditions to restrict access by IP, time, or MFA
- Rotate credentials regularly
- Use permission boundaries for delegated administration
Policy Design
- Start with AWS managed policies, customize as needed
- Use policy variables (
${aws:username}) for dynamic policies - Prefer explicit denies for sensitive actions
- Group related permissions logically
Monitoring
- Enable CloudTrail for API auditing
- Use IAM Access Analyzer to identify overly permissive policies
- Review credential reports regularly
- Set up alerts for root account usage
Troubleshooting
Access Denied Errors
Symptom: AccessDeniedException or UnauthorizedAccess
Debug steps:
- Verify identity:
aws sts get-caller-identity - Check attached policies:
aws iam list-attached-role-policies --role-name MyRole - Simulate the action:
aws iam simulate-principal-policy \ --policy-source-arn arn:aws:iam::123456789012:role/MyRole \ --action-names dynamodb:GetItem \ --resource-arns arn:aws:dynamodb:us-east-1:123456789012:table/MyTable - Check for explicit denies in SCPs or permission boundaries
- Verify resource-based policies allow the principal
Role Cannot Be Assumed
Symptom: AccessDenied when calling AssumeRole
Causes:
- Trust policy doesn't include the calling principal
- Missing
sts:AssumeRolepermission on the caller - ExternalId mismatch (for cross-account roles)
- Session duration exceeds maximum
Fix: Review and update the role's trust relationship.
Policy Size Limits
- Managed policy: 6,144 characters
- Inline policy: 2,048 characters (user), 10,240 characters (role/group)
- Trust policy: 2,048 characters
Solution: Use multiple policies, reference resources by prefix/wildcard, or use tags-based access control.
References
More by itsmostafa
View all skills by itsmostafa →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversSecurely manage Clerk authentication, users, sessions, orgs, and authorization for seamless identity and access control.
Keycloak Admin plugin enables seamless user and realm management for automated identity and access control solutions.
Official Okta MCP server for managing identity and access management through AI. Automate user provisioning, group manag
ACMS gives programmatic access to Apple's macOS container CLI for Apple Silicon containers, enabling Apple container man
AI-ready PingOne Advanced Identity Cloud MCP Server — securely manage users, customize auth themes, query identity data,
iExec MCP Server — AI agents handle confidential computing, decentralized data governance, Web3Mail, and blockchain wall
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.