DevOps & Cloud · Cheatsheet
AWS CLI Cheatsheet
S3, EC2, IAM, Lambda, ECS, CloudFormation, and essential AWS CLI commands
58 commands 9 sections
No entry matches that filter.
-
aws configureSet up access key, secret, region, output -
aws configure listShow current configuration values -
aws sts get-caller-identityShow current IAM user/role -
aws configure set region us-east-1Set default region -
aws configure --profile stagingSet up named profile -
export AWS_PROFILE=stagingSwitch to named profile -
aws configure list-profilesList all configured profiles
-
aws s3 lsList all S3 buckets -
aws s3 ls s3://bucket-name/List objects in a bucket -
aws s3 cp file.txt s3://bucket/path/Upload file to S3 -
aws s3 cp s3://bucket/file.txt ./Download file from S3 -
aws s3 sync ./dir s3://bucket/prefix/Sync local directory to S3 -
aws s3 rm s3://bucket/file.txtDelete file from S3 -
aws s3 rm s3://bucket/ --recursiveDelete all objects in bucket -
aws s3 mb s3://new-bucketCreate a new S3 bucket -
aws s3 rb s3://bucket --forceDelete bucket and all contents -
aws s3 presign s3://bucket/file --expires-in 3600Generate presigned URL (1 hour)
-
aws ec2 describe-instancesList all EC2 instances -
aws ec2 describe-instances --filters "Name=tag:Name,Values=web"Filter instances by tag -
aws ec2 start-instances --instance-ids i-xxxStart an EC2 instance -
aws ec2 stop-instances --instance-ids i-xxxStop an EC2 instance -
aws ec2 terminate-instances --instance-ids i-xxxTerminate an EC2 instance -
aws ec2 describe-security-groupsList security groups -
aws ec2 describe-vpcsList VPCs -
aws ec2 describe-subnetsList subnets
-
aws iam list-usersList all IAM users -
aws iam list-rolesList all IAM roles -
aws iam list-policies --scope LocalList custom IAM policies -
aws iam get-user --user-name devShow user details -
aws iam create-user --user-name devCreate a new IAM user -
aws iam attach-user-policy --user-name dev --policy-arn <arn>Attach policy to user -
aws iam create-access-key --user-name devGenerate access key for user
-
aws lambda list-functionsList all Lambda functions -
aws lambda invoke --function-name fn out.jsonInvoke a Lambda function -
aws lambda get-function --function-name fnShow function configuration -
aws lambda update-function-code --function-name fn --zip-file fileb://code.zipDeploy new function code -
aws lambda list-event-source-mappingsList event source triggers -
aws logs tail /aws/lambda/fn --followTail Lambda CloudWatch logs
-
aws ecr get-login-password | docker login --username AWS --password-stdin <acct>.dkr.ecr.<region>.amazonaws.comLogin to ECR registry -
aws ecr describe-repositoriesList ECR repositories -
aws ecs list-clustersList ECS clusters -
aws ecs list-services --cluster my-clusterList services in cluster -
aws ecs describe-services --cluster my-cluster --services my-svcShow service details -
aws ecs update-service --cluster my-cluster --service my-svc --force-new-deploymentForce new deployment
-
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETEList active stacks -
aws cloudformation deploy --template-file tpl.yaml --stack-name my-stackDeploy/update a stack -
aws cloudformation describe-stack-events --stack-name my-stackShow stack events -
aws cloudformation delete-stack --stack-name my-stackDelete a stack -
aws ssm get-parameter --name /app/db-password --with-decryptionGet SSM parameter value -
aws ssm put-parameter --name /app/key --value "val" --type SecureStringStore encrypted parameter
-
--region us-west-2Override default region -
--output jsonOutput as JSON (default) -
--output tableOutput as formatted table -
--output textOutput as tab-separated text -
--query "Reservations[].Instances[].InstanceId"JMESPath query to filter output -
--no-paginateDisable automatic pagination -
--dry-runCheck permissions without executing
-
https://docs.aws.amazon.com/cli/latest/reference/AWS CLI v2 reference: service commands, parameters, profiles, and output options.