AWS CLI Cheat Sheet: aws Commands with Examples

The AWS CLI commands you use most, grouped by job, with a working example for each. Names such as my-bucket, alice and i-0123456789abcdef0 are examples: swap in your own. Bookmark this page or download the free PDF.

Download the free PDF

Set up and check who you are

Command What it does
aws configure Prompts for an access key, secret key, default Region and output format
aws configure list Show the settings and credentials the CLI is using
aws configure list-profiles List the profiles you have set up
aws configure set region eu-west-1 Change the default Region in your config
aws configure sso Set up a profile for IAM Identity Center sign-in
aws sso login --profile myprofile Sign in again when your SSO session expires
aws sts get-caller-identity Show the account and identity your commands run as
aws --version Show the CLI version

Remember: Run aws sts get-caller-identity before you change anything, so you know which account you are in.

S3 (high-level aws s3 commands)

Command What it does
aws s3 ls List your buckets
aws s3 ls s3://my-bucket --recursive --human-readable --summarize List every object with sizes and a total
aws s3 mb s3://my-bucket Create a bucket
aws s3 cp report.pdf s3://my-bucket/ Upload a file
aws s3 cp s3://my-bucket/report.pdf . Download a file to the current folder
aws s3 cp ./docs s3://my-bucket/docs --recursive Upload a whole folder
aws s3 mv s3://my-bucket/old.txt s3://my-bucket/new.txt Move or rename an object
aws s3 sync ./site s3://my-bucket --delete Make the bucket match a folder, deleting extra objects
aws s3 rm s3://my-bucket/report.pdf Delete one object
aws s3 rm s3://my-bucket --recursive Delete every object in a bucket
aws s3 rb s3://my-bucket --force Delete a bucket and its contents
aws s3 presign s3://my-bucket/report.pdf --expires-in 3600 Make a temporary download link (1 hour)

Remember: sync with --delete removes anything in the destination that is not in the source.

S3 (aws s3api commands)

Command What it does
aws s3api list-buckets List buckets as JSON
aws s3api get-bucket-versioning --bucket my-bucket Check whether versioning is on
aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Enabled Turn versioning on
aws s3api list-object-versions --bucket my-bucket List every version of every object

EC2

Command What it does
aws ec2 describe-instances List instances as JSON
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].InstanceId" --output text IDs of running instances only
aws ec2 run-instances --image-id ami-0abcdef1234567890 --instance-type t3.micro --key-name my-key --count 1 Launch an instance (use an AMI ID from your Region)
aws ec2 stop-instances --instance-ids i-0123456789abcdef0 Stop an instance (it can be started again)
aws ec2 start-instances --instance-ids i-0123456789abcdef0 Start a stopped instance
aws ec2 reboot-instances --instance-ids i-0123456789abcdef0 Reboot an instance
aws ec2 terminate-instances --instance-ids i-0123456789abcdef0 Delete an instance for good
aws ec2 create-key-pair --key-name my-key --query "KeyMaterial" --output text Create a key pair and print the private key
aws ec2 describe-security-groups List security groups
aws ec2 authorize-security-group-ingress --group-id sg-0123456789abcdef0 --protocol tcp --port 22 --cidr 203.0.113.0/24 Allow SSH from one address range
aws ec2 describe-vpcs List VPCs
aws ec2 describe-regions --output table List the Regions available to you
aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 --description "before upgrade" Snapshot an EBS volume

Remember: Add --dry-run to many EC2 commands to test your permissions without making the change.

IAM

Command What it does
aws iam list-users List IAM users
aws iam create-user --user-name alice Create a user
aws iam attach-user-policy --user-name alice --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess Attach a managed policy to a user
aws iam list-attached-user-policies --user-name alice Policies attached to a user
aws iam create-access-key --user-name alice Create an access key (the secret is shown once)
aws iam list-roles List roles
aws iam get-role --role-name my-role Show one role and its trust policy
aws iam delete-user --user-name alice Delete a user (remove its keys and policies first)

Remember: Prefer roles and IAM Identity Center over long-lived access keys.

Lambda and CloudFormation

Command What it does
aws lambda list-functions List functions
aws lambda invoke --function-name my-func --payload '{"key":"value"}' --cli-binary-format raw-in-base64-out out.json Run a function and save the response to out.json
aws lambda update-function-code --function-name my-func --zip-file fileb://function.zip Upload new code from a zip file
aws cloudformation validate-template --template-body file://template.yaml Check a template for syntax errors
aws cloudformation deploy --template-file template.yaml --stack-name my-stack --capabilities CAPABILITY_IAM Create or update a stack
aws cloudformation describe-stacks --stack-name my-stack Status and outputs of a stack
aws cloudformation describe-stack-events --stack-name my-stack Event history, to find why a deployment failed
aws cloudformation delete-stack --stack-name my-stack Delete a stack and its resources

Logs, metrics and parameters

Command What it does
aws logs describe-log-groups List CloudWatch log groups
aws logs tail /aws/lambda/my-func --follow Stream a log group to your terminal
aws cloudwatch list-metrics --namespace AWS/EC2 List the metrics in a namespace
aws cloudwatch describe-alarms List alarms
aws ssm get-parameter --name /app/db-host --with-decryption Read a Parameter Store value
aws ssm put-parameter --name /app/db-host --value example --type String --overwrite Write a Parameter Store value
aws ssm describe-instance-information List instances managed by Systems Manager
aws rds describe-db-instances List RDS database instances

Output, queries and global options

Command What it does
aws ec2 describe-instances --output table Human-friendly table (also json, text, yaml)
aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output text Pick fields with a JMESPath query
aws s3 ls --profile myprofile Use a named profile for one command
aws ec2 describe-instances --region us-east-1 Run against another Region
aws ec2 describe-instances --no-cli-pager Print straight to the terminal, no pager
aws s3 ls --debug Verbose output to see what the CLI is doing

Remember: The --query option uses JMESPath and is applied by the CLI after the service replies.

Help

Command What it does
aws help Top-level help
aws ec2 help Help for a service
aws ec2 run-instances help Help for one command, with examples

Common mistakes

  • aws s3 sync --delete deletes objects in the destination that are not in the source. Check which side is which before you run it.
  • aws s3 rb --force and aws s3 rm --recursive remove every object. There is no recycle bin unless versioning is on.
  • stop-instances can be reversed with start-instances. terminate-instances cannot.
  • On AWS CLI v2, aws lambda invoke --payload with a JSON string needs --cli-binary-format raw-in-base64-out.
  • Commands act on the default Region and profile unless you add --region or --profile. Check with aws sts get-caller-identity.
  • --query uses JMESPath, which is case sensitive and quote-sensitive. Quoting differs between Bash and PowerShell.

AWS CLI FAQ

How do I check which AWS account I am using?
aws sts get-caller-identity prints the account ID and the identity your commands run as.

How do I switch profile or Region?
Add --profile NAME or --region REGION to a command, or change the default with aws configure.

How do I list resources in a table?
Add --output table to the command. Other formats include json, text and yaml.

How do I filter the output?
Use --query with a JMESPath expression, for example aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output text.

Practise it

Learning AWS? Try the free AWS SAA-C03 practice test or the free AWS SOA-C03 practice test, and read our SOA-C03 domains guide.


Commands and options follow the AWS CLI version 2 command reference on docs.aws.amazon.com (the configure, sso, sts, s3, s3api, ec2, iam, lambda, cloudformation, logs, cloudwatch, ssm and rds pages, plus the global options page), checked on 17 November 2026. Resource names, IDs and Regions are examples. Commands change between CLI versions, so run the help command for your installed version before relying on a flag.


Studying for AWS exams? See the AWS SAA-C03 real exam questions and the AWS SOA-C03 real exam questions.

What people say about this pack

Pass today SAA-C03 Exam, All questions in your dumps was very helpful, also explanation included in all questions help me a lot, I take two weeks to prepare and on exam day I Ace exam, Thanks for valid exam questions.
Sathish
Pass my AWS Solutions Architect Associate yesterday, And most of questions in real exam were exactly same as you have provided in your SAA-C03 Dumps.
Arpit Dhman
Back to blog