AWS CLI Cheat Sheet
AWS CLI commands for S3, EC2, Lambda, IAM, and other core services.
3 PagesIntermediateApr 30, 2026
S3
Object storage commands.
bash
aws s3 ls # List bucketsaws s3 cp file.txt s3://my-bucket/ # Uploadaws s3 sync ./dist s3://my-bucket/ # Sync a folderaws s3 rm s3://my-bucket/file.txt # Delete object
EC2
Compute instance commands.
bash
aws ec2 describe-instancesaws ec2 start-instances --instance-ids i-0abc123aws ec2 stop-instances --instance-ids i-0abc123
Lambda
Serverless function commands.
bash
aws lambda invoke --function-name myFunc out.jsonaws lambda update-function-code \ --function-name myFunc --zip-file fileb://code.zip
IAM
Identity and access management.
bash
aws iam list-usersaws iam create-user --user-name newuseraws iam attach-user-policy --user-name newuser \ --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
DynamoDB
Common table and item operations with the AWS CLI.
bash
# Create a tableaws dynamodb create-table --table-name Users \ --attribute-definitions AttributeName=id,AttributeType=S \ --key-schema AttributeName=id,KeyType=HASH \ --billing-mode PAY_PER_REQUEST# Put and get an itemaws dynamodb put-item --table-name Users \ --item '{"id":{"S":"u1"},"name":{"S":"Ada"}}'aws dynamodb get-item --table-name Users \ --key '{"id":{"S":"u1"}}'# Query with a key condition expressionaws dynamodb query --table-name Users \ --key-condition-expression 'id = :v' \ --expression-attribute-values '{":v":{"S":"u1"}}'
CloudFormation
Deploy and manage infrastructure stacks.
bash
# Validate a templateaws cloudformation validate-template --template-body file://stack.yaml# Deploy (create or update) a stackaws cloudformation deploy --template-file stack.yaml \ --stack-name my-stack \ --parameter-overrides Env=prod \ --capabilities CAPABILITY_NAMED_IAM# Watch events and deleteaws cloudformation describe-stack-events --stack-name my-stackaws cloudformation delete-stack --stack-name my-stackaws cloudformation wait stack-delete-complete --stack-name my-stack
CloudWatch Logs
Tail and query application log streams.
bash
# Live tail a log group (CLI v2)aws logs tail /aws/lambda/my-fn --follow --since 10m# List log groups and streamsaws logs describe-log-groups --log-group-name-prefix /aws/lambda# Run a Logs Insights queryaws logs start-query --log-group-name /aws/lambda/my-fn \ --start-time $(date -d '-1 hour' +%s) --end-time $(date +%s) \ --query-string 'fields @timestamp, @message | sort @timestamp desc | limit 20'
Global Flags & Config
Options that apply to nearly every AWS CLI command.
- --profile <name>- use a named credential/config profile from ~/.aws/credentials
- --region <region>- override the default region for a single command
- --output json|table|text|yaml- control the response format
- --query <JMESPath>- filter/transform output server-side style with a JMESPath expression
- --dry-run- check permissions for EC2 actions without executing them
- --no-cli-pager- disable the pager so output prints straight to stdout
- aws sso login- authenticate a profile configured for IAM Identity Center (SSO)
Pro Tip
Configure named profiles (aws configure --profile name) to safely switch between multiple AWS accounts.
Was this cheat sheet helpful?
Explore Topics
#AWSCLI#AWSCLICheatSheet#CloudComputing#Intermediate#EC2#Lambda#IAM#DynamoDB#Functions#CommandLine#CheatSheet#SkillVeris