| name | aws-cli-playbook |
| description | Canonical AWS CLI patterns for discover, plan, deploy, validate, and rollback |
| version | 1.0.0 |
| category | aws |
| agents | ["aws-coworker-core","aws-coworker-planner","aws-coworker-executor"] |
| tools | ["Bash","Read"] |
AWS CLI Playbook
Purpose
This skill provides canonical AWS CLI patterns for safe, effective AWS interactions. It covers discovery, planning, deployment, validation, and rollback patterns across major AWS services.
When to Use
- Discovering AWS resources and current state
- Planning AWS operations and changes
- Executing approved changes via CLI
- Validating changes and outcomes
- Rolling back failed or unwanted changes
When NOT to Use
- Production changes (use IaC via CI/CD instead)
- Complex multi-resource deployments (prefer CDK/Terraform)
- One-off scripts that should be IaC
Core Principles
1. Always Specify Profile and Region
aws ec2 describe-instances \
--profile dev-admin \
--region us-east-1
2. Use Output Formatting
aws ec2 describe-instances --output json
aws ec2 describe-instances --output table
aws ec2 describe-instances --output text
aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].[InstanceId,State.Name,Tags[?Key==`Name`].Value|[0]]' \
--output table
3. Use Dry Run When Available
aws ec2 run-instances --dry-run ...
aws ec2 terminate-instances --dry-run ...
4. Capture Output for Validation
RESULT=$(aws ec2 run-instances ... --output json)
INSTANCE_ID=$(echo $RESULT | jq -r '.Instances[0].InstanceId')
echo "Created instance: $INSTANCE_ID"
Discovery Patterns
Identity and Access
aws sts get-caller-identity --profile {profile}
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::123456789012:user/myuser \
--action-names ec2:DescribeInstances ec2:RunInstances \
--profile {profile}
aws iam list-roles --profile {profile}
EC2
aws ec2 describe-instances \
--profile {profile} \
--region {region}
aws ec2 describe-instances \
--filters "Name=instance-state-name,Values=running" \
--profile {profile} \
--region {region}
aws ec2 describe-instances \
--filters "Name=tag:Environment,Values=production" \
--profile {profile} \
--region {region}
aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].[InstanceId,InstanceType,State.Name,Tags[?Key==`Name`].Value|[0],PrivateIpAddress]' \
--output table \
--profile {profile} \
--region {region}
VPC and Networking
aws ec2 describe-vpcs \
--profile {profile} \
--region {region}
aws ec2 describe-subnets \
--query 'Subnets[*].[SubnetId,VpcId,CidrBlock,AvailabilityZone,Tags[?Key==`Name`].Value|[0]]' \
--output table \
--profile {profile} \
--region {region}
aws ec2 describe-security-groups \
--profile {profile} \
--region {region}
aws ec2 describe-security-groups \
--query 'SecurityGroups[?IpPermissions[?IpRanges[?CidrIp==`0.0.0.0/0`]]].[GroupId,GroupName,Description]' \
--output table \
--profile {profile} \
--region {region}
S3
aws s3 ls --profile {profile}
aws s3api get-bucket-location --bucket {bucket} --profile {profile}
aws s3api get-bucket-versioning --bucket {bucket} --profile {profile}
aws s3api get-bucket-encryption --bucket {bucket} --profile {profile}
aws s3api get-public-access-block --bucket {bucket} --profile {profile}
aws s3 ls s3://{bucket} --recursive --summarize --profile {profile}
RDS
aws rds describe-db-instances \
--profile {profile} \
--region {region}
aws rds describe-db-instances \
--query 'DBInstances[*].[DBInstanceIdentifier,DBInstanceClass,Engine,DBInstanceStatus]' \
--output table \
--profile {profile} \
--region {region}
aws rds describe-db-clusters \
--profile {profile} \
--region {region}
Lambda
aws lambda list-functions \
--profile {profile} \
--region {region}
aws lambda get-function \
--function-name {function-name} \
--profile {profile} \
--region {region}
aws lambda list-functions \
--query 'Functions[*].[FunctionName,Runtime,MemorySize,Timeout]' \
--output table \
--profile {profile} \
--region {region}
IAM
aws iam list-users --profile {profile}
aws iam list-roles \
--query 'Roles[*].[RoleName,Arn,CreateDate]' \
--output table \
--profile {profile}
aws iam list-attached-role-policies --role-name {role} --profile {profile}
aws iam list-role-policies --role-name {role} --profile {profile}
aws iam get-role-policy --role-name {role} --policy-name {policy} --profile {profile}
CloudFormation
aws cloudformation list-stacks \
--stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE \
--profile {profile} \
--region {region}
aws cloudformation describe-stacks \
--stack-name {stack} \
--profile {profile} \
--region {region}
aws cloudformation list-stack-resources \
--stack-name {stack} \
--profile {profile} \
--region {region}
aws cloudformation describe-stack-events \
--stack-name {stack} \
--profile {profile} \
--region {region}
Safe Mutation Patterns
EC2 Instance Management
aws ec2 start-instances \
--instance-ids i-xxxxxxxxx \
--profile {profile} \
--region {region}
aws ec2 stop-instances \
--instance-ids i-xxxxxxxxx \
--profile {profile} \
--region {region}
aws ec2 terminate-instances \
--instance-ids i-xxxxxxxxx \
--profile {profile} \
--region {region}
Security Group Rules
aws ec2 authorize-security-group-ingress \
--group-id sg-xxxxxxxxx \
--protocol tcp \
--port 443 \
--cidr 10.0.0.0/8 \
--profile {profile} \
--region {region}
aws ec2 revoke-security-group-ingress \
--group-id sg-xxxxxxxxx \
--protocol tcp \
--port 22 \
--cidr 0.0.0.0/0 \
--profile {profile} \
--region {region}
S3 Operations
aws s3 cp local-file.txt s3://{bucket}/path/ --profile {profile}
aws s3 sync ./local-dir s3://{bucket}/path/ --profile {profile}
aws s3 rm s3://{bucket}/path/file.txt --profile {profile}
aws s3 rm s3://{bucket} --recursive --profile {profile}
Tags
aws ec2 create-tags \
--resources i-xxxxxxxxx \
--tags Key=Environment,Value=production Key=Owner,Value=platform-team \
--profile {profile} \
--region {region}
aws ec2 delete-tags \
--resources i-xxxxxxxxx \
--tags Key=Temporary \
--profile {profile} \
--region {region}
IaC Deployment Patterns
CloudFormation
aws cloudformation create-stack \
--stack-name {stack-name} \
--template-body file://template.yaml \
--parameters ParameterKey=Environment,ParameterValue=dev \
--capabilities CAPABILITY_IAM \
--tags Key=Environment,Value=dev \
--profile {profile} \
--region {region}
aws cloudformation create-change-set \
--stack-name {stack-name} \
--change-set-name {change-set-name} \
--template-body file://template.yaml \
--profile {profile} \
--region {region}
aws cloudformation describe-change-set \
--stack-name {stack-name} \
--change-set-name {change-set-name} \
--profile {profile} \
--region {region}
aws cloudformation execute-change-set \
--stack-name {stack-name} \
--change-set-name {change-set-name} \
--profile {profile} \
--region {region}
aws cloudformation wait stack-update-complete \
--stack-name {stack-name} \
--profile {profile} \
--region {region}
CDK
cdk synth --profile {profile}
cdk diff --profile {profile}
cdk deploy --profile {profile} --require-approval broadening
cdk deploy MyStack --profile {profile}
Terraform
terraform init
terraform plan -var-file={env}.tfvars -out=plan.tfplan
terraform apply plan.tfplan
terraform apply -var-file={env}.tfvars -auto-approve
Rollback Patterns
CloudFormation Rollback
aws cloudformation update-stack \
--stack-name {stack-name} \
--use-previous-template \
--parameters ParameterKey=SomeParam,UsePreviousValue=true \
--profile {profile} \
--region {region}
aws cloudformation delete-stack \
--stack-name {stack-name} \
--profile {profile} \
--region {region}
aws cloudformation cancel-update-stack \
--stack-name {stack-name} \
--profile {profile} \
--region {region}
EC2 Recovery
aws ec2 create-volume \
--snapshot-id snap-xxxxxxxxx \
--availability-zone {az} \
--profile {profile} \
--region {region}
aws ec2 run-instances \
--image-id ami-xxxxxxxxx \
--instance-type {type} \
--profile {profile} \
--region {region}
S3 Recovery
aws s3api list-object-versions \
--bucket {bucket} \
--prefix {key} \
--profile {profile}
aws s3api copy-object \
--bucket {bucket} \
--copy-source {bucket}/{key}?versionId={version-id} \
--key {key} \
--profile {profile}
Related Files
Detailed service-specific commands are in:
commands/bedrock.md - Bedrock patterns (model access, inference, guardrails)
commands/bedrock-agentcore.md - Bedrock AgentCore patterns (agent runtimes, identity, gateway)
commands/cloudformation.md - CloudFormation patterns
commands/ec2.md - EC2 patterns
commands/ecs.md - ECS patterns
commands/eks.md - EKS patterns
commands/iam.md - IAM patterns
commands/lambda.md - Lambda patterns
commands/organizations.md - Organizations patterns
commands/rds.md - RDS patterns
commands/s3.md - S3 patterns
commands/vpc.md - VPC/networking patterns
Related Skills
aws-well-architected — Architectural alignment
aws-governance-guardrails — Policy compliance
aws-org-strategy — Multi-account context