AWS CLI Cheatsheet
Quick reference for AWS CLI commands covering EC2, S3, IAM, Lambda, CloudFormation, RDS, ECS, and general operations
56 commands
aws configureConfigure AWS CLI credentials and default settings
aws configureaws configure listList current configuration values
aws configure listaws sts get-caller-identityCheck IAM identity of current credentials
aws sts get-caller-identityaws --profileExecute with a named profile
aws --profile production s3 lsaws --regionExecute command with specified region
aws --region us-west-2 ec2 describe-instancesaws --outputSpecify output format (json/table/text/yaml)
aws ec2 describe-instances --output tableaws --queryFilter output with JMESPath query
aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId'aws ec2 describe-instancesDescribe EC2 instances
aws ec2 describe-instances --filters 'Name=instance-state-name,Values=running'aws ec2 run-instancesLaunch a new EC2 instance
aws ec2 run-instances --image-id ami-0abcdef --instance-type t3.micro --key-name mykeyaws ec2 start-instancesStart stopped EC2 instances
aws ec2 start-instances --instance-ids i-1234567890abcdef0aws ec2 stop-instancesStop EC2 instances
aws ec2 stop-instances --instance-ids i-1234567890abcdef0aws ec2 terminate-instancesTerminate (delete) EC2 instances
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0aws ec2 describe-security-groupsDescribe security groups
aws ec2 describe-security-groups --group-ids sg-12345678aws ec2 create-key-pairCreate a key pair
aws ec2 create-key-pair --key-name mykey --query 'KeyMaterial' --output text > mykey.pemaws ec2 describe-vpcsDescribe VPCs
aws ec2 describe-vpcsaws ec2 describe-subnetsDescribe subnets
aws ec2 describe-subnets --filters 'Name=vpc-id,Values=vpc-12345'aws ec2 create-imageCreate AMI from EC2 instance
aws ec2 create-image --instance-id i-123456 --name 'backup-image'aws s3 lsList S3 buckets or objects
aws s3 ls s3://my-bucket/prefix/aws s3 cpCopy files to/from S3
aws s3 cp file.txt s3://my-bucket/aws s3 syncSync directory with S3 bucket
aws s3 sync ./dist s3://my-bucket/ --deleteaws s3 mbCreate S3 bucket
aws s3 mb s3://my-new-bucket --region ap-northeast-1aws s3 rbRemove S3 bucket
aws s3 rb s3://my-bucket --forceaws s3 rmRemove S3 objects
aws s3 rm s3://my-bucket/file.txtaws s3 presignGenerate presigned URL for S3 object
aws s3 presign s3://my-bucket/file.zip --expires-in 3600aws s3api put-bucket-policySet S3 bucket policy
aws s3api put-bucket-policy --bucket my-bucket --policy file://policy.jsonaws iam create-userCreate IAM user
aws iam create-user --user-name newuseraws iam list-usersList IAM users
aws iam list-usersaws iam create-roleCreate IAM role
aws iam create-role --role-name MyRole --assume-role-policy-document file://trust.jsonaws iam attach-role-policyAttach policy to IAM role
aws iam attach-role-policy --role-name MyRole --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccessaws iam create-access-keyCreate access key
aws iam create-access-key --user-name myuseraws iam list-policiesList IAM policies
aws iam list-policies --scope Localaws sts assume-roleAssume an IAM role
aws sts assume-role --role-arn arn:aws:iam::123456:role/MyRole --role-session-name session1aws lambda list-functionsList Lambda functions
aws lambda list-functions --region ap-northeast-1aws lambda invokeInvoke a Lambda function
aws lambda invoke --function-name myFunc --payload '{"key":"val"}' output.jsonaws lambda create-functionCreate a Lambda function
aws lambda create-function --function-name myFunc --runtime nodejs20.x --handler index.handler --zip-file fileb://func.zip --role arn:aws:iam::123:role/lambda-roleaws lambda update-function-codeUpdate Lambda function code
aws lambda update-function-code --function-name myFunc --zip-file fileb://func.zipaws lambda get-functionGet Lambda function configuration
aws lambda get-function --function-name myFuncaws lambda delete-functionDelete a Lambda function
aws lambda delete-function --function-name myFuncaws cloudformation create-stackCreate CloudFormation stack
aws cloudformation create-stack --stack-name mystack --template-body file://template.yamlaws cloudformation update-stackUpdate CloudFormation stack
aws cloudformation update-stack --stack-name mystack --template-body file://template.yamlaws cloudformation delete-stackDelete CloudFormation stack
aws cloudformation delete-stack --stack-name mystackaws cloudformation describe-stacksDescribe stacks
aws cloudformation describe-stacks --stack-name mystackaws cloudformation list-stacksList stacks
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETEaws cloudformation validate-templateValidate template syntax
aws cloudformation validate-template --template-body file://template.yamlaws rds describe-db-instancesDescribe RDS instances
aws rds describe-db-instancesaws rds create-db-instanceCreate RDS instance
aws rds create-db-instance --db-instance-identifier mydb --db-instance-class db.t3.micro --engine mysql --master-username admin --master-user-password passaws rds create-db-snapshotCreate RDS snapshot
aws rds create-db-snapshot --db-instance-identifier mydb --db-snapshot-identifier mydb-snapaws rds delete-db-instanceDelete RDS instance
aws rds delete-db-instance --db-instance-identifier mydb --skip-final-snapshotaws rds modify-db-instanceModify RDS instance configuration
aws rds modify-db-instance --db-instance-identifier mydb --db-instance-class db.t3.mediumaws rds describe-db-clustersDescribe Aurora clusters
aws rds describe-db-clustersaws ecs list-clustersList ECS clusters
aws ecs list-clustersaws ecs list-servicesList ECS services
aws ecs list-services --cluster my-clusteraws ecs describe-tasksDescribe ECS tasks
aws ecs describe-tasks --cluster my-cluster --tasks task-idaws ecs create-serviceCreate ECS service
aws ecs create-service --cluster my-cluster --service-name my-svc --task-definition my-task:1 --desired-count 2aws ecs update-serviceUpdate (deploy) ECS service
aws ecs update-service --cluster my-cluster --service my-svc --force-new-deploymentaws ecs register-task-definitionRegister task definition
aws ecs register-task-definition --cli-input-json file://task-def.json