DevOpsil
AWS CLI33 commands

AWS CLI Cheat Sheet

Essential AWS CLI commands for EC2, S3, IAM, Lambda, ECS, CloudFormation, and account management.

Configuration

CommandDescription
aws configure
Set up access key, secret, and region
aws configure list
Show current config
aws sts get-caller-identity
Show current IAM identity
aws configure --profile staging
Configure named profile
export AWS_PROFILE=staging
Switch active profile

S3

CommandDescription
aws s3 ls
List buckets
aws s3 ls s3://<bucket>/
List objects in bucket
aws s3 cp file.txt s3://<bucket>/
Upload file
aws s3 cp s3://<bucket>/file.txt .
Download file
aws s3 sync ./dir s3://<bucket>/dir
Sync local dir to S3
aws s3 rm s3://<bucket>/file.txt
Delete object
aws s3 mb s3://<bucket>
Create bucket
aws s3 presign s3://<bucket>/file.txt --expires-in 3600
Generate pre-signed URL

EC2

CommandDescription
aws ec2 describe-instances
List all instances
aws ec2 start-instances --instance-ids <id>
Start instance
aws ec2 stop-instances --instance-ids <id>
Stop instance
aws ec2 terminate-instances --instance-ids <id>
Terminate instance
aws ec2 describe-security-groups
List security groups
aws ec2 describe-vpcs
List VPCs

IAM

CommandDescription
aws iam list-users
List IAM users
aws iam list-roles
List IAM roles
aws iam get-user
Get current user details
aws iam list-attached-user-policies --user-name <name>
List user policies
aws iam create-access-key --user-name <name>
Create access key

Lambda & ECS

CommandDescription
aws lambda list-functions
List Lambda functions
aws lambda invoke --function-name <name> out.json
Invoke function
aws ecs list-clusters
List ECS clusters
aws ecs list-services --cluster <name>
List services in cluster
aws ecs describe-tasks --cluster <c> --tasks <arn>
Describe ECS task

CloudFormation

CommandDescription
aws cloudformation deploy --template-file t.yml --stack-name <s>
Deploy stack
aws cloudformation describe-stacks
List stacks
aws cloudformation delete-stack --stack-name <s>
Delete stack
aws cloudformation describe-stack-events --stack-name <s>
View stack events