Cheatsheet
AWS CLI Cheatsheet
A practical reference for configuring the AWS CLI and common usage of AWS services.
- AWS
- AWS CLI v2
•1 min read
Configure the CLI
If using SSO: IAM Identity Center, you can log in with:
terminal
# You will be prompted for an SSO session name, Default client Region, Output format and Login with URL.
aws configure sso
# To login after configuring SSO.
aws sso loginIdentity and account
terminal
# Show the active IAM identity
aws sts get-caller-identity
# List IAM users
aws iam list-usersCompute
EC2
terminal
# List instances
aws ec2 describe-instances
# Start, stop, or reboot an instance
aws ec2 start-instances --instance-ids i-1234567890abcdef0
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
aws ec2 reboot-instances --instance-ids i-1234567890abcdef0Lambda
terminal
aws lambda list-functions
aws lambda invoke --function-name MyFunction output.jsonECS and EKS
terminal
aws ecs list-clusters
aws ecs list-services --cluster my-cluster
aws ecs list-tasks --cluster my-cluster
aws eks list-clusters
aws eks update-kubeconfig --region us-east-1 --name my-clusterStorage and containers
S3
terminal
# List buckets and files
aws s3 ls
aws s3 ls s3://my-bucket
# Copy, sync, and remove files
aws s3 cp file.txt s3://my-bucket/
aws s3 sync ./folder s3://my-bucket/folder
aws s3 rm s3://my-bucket/file.txtECR login
terminal
aws ecr get-login-password \
| docker login \
--username AWS \
--password-stdin <account-id>.dkr.ecr.<region>.amazonaws.comData, logs, and infrastructure
terminal
# CloudWatch
aws logs describe-log-groups
aws logs describe-log-streams --log-group-name /aws/lambda/MyFunction
# RDS
aws rds describe-db-instances
aws rds start-db-instance --db-instance-identifier mydb
aws rds stop-db-instance --db-instance-identifier mydb
# DynamoDB
aws dynamodb list-tables
aws dynamodb scan --table-name MyTable
# CloudFormation
aws cloudformation list-stacks
aws cloudformation describe-stacks --stack-name my-stackGlobal options
| Need | Command |
|---|---|
| Use a region | aws ec2 describe-instances --region us-west-2 |
| Use a profile | aws s3 ls --profile dev |
| Format output | aws ec2 describe-instances --output table |
| Filter with JMESPath | aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,State.Name]" |
Help
terminal
aws help
aws ec2 help
aws ec2 describe-instances help
aws --version