---
title: "AWS CLI Cheatsheet | FindUtils"
description: "S3, EC2, IAM, Lambda, ECS, CloudFormation, and essential AWS CLI commands"
url: https://findutils.com/cheatsheets/aws-cli/
---

# AWS CLI Cheatsheet

S3, EC2, IAM, Lambda, ECS, CloudFormation, and essential AWS CLI commands 58 commands in 9 sections, filed under [DevOps & Cloud](https://findutils.com/cheatsheets/devops/).

## Configuration & Identity

- `aws configure`: Set up access key, secret, region, output
- `aws configure list`: Show current configuration values
- `aws sts get-caller-identity`: Show current IAM user/role
- `aws configure set region us-east-1`: Set default region
- `aws configure --profile staging`: Set up named profile
- `export AWS_PROFILE=staging`: Switch to named profile
- `aws configure list-profiles`: List all configured profiles

## S3 (Storage)

- `aws s3 ls`: List 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.txt`: Delete file from S3
- `aws s3 rm s3://bucket/ --recursive`: Delete all objects in bucket
- `aws s3 mb s3://new-bucket`: Create a new S3 bucket
- `aws s3 rb s3://bucket --force`: Delete bucket and all contents
- `aws s3 presign s3://bucket/file --expires-in 3600`: Generate presigned URL (1 hour)

## EC2 (Compute)

- `aws ec2 describe-instances`: List all EC2 instances
- `aws ec2 describe-instances --filters "Name=tag:Name,Values=web"`: Filter instances by tag
- `aws ec2 start-instances --instance-ids i-xxx`: Start an EC2 instance
- `aws ec2 stop-instances --instance-ids i-xxx`: Stop an EC2 instance
- `aws ec2 terminate-instances --instance-ids i-xxx`: Terminate an EC2 instance
- `aws ec2 describe-security-groups`: List security groups
- `aws ec2 describe-vpcs`: List VPCs
- `aws ec2 describe-subnets`: List subnets

## IAM (Identity)

- `aws iam list-users`: List all IAM users
- `aws iam list-roles`: List all IAM roles
- `aws iam list-policies --scope Local`: List custom IAM policies
- `aws iam get-user --user-name dev`: Show user details
- `aws iam create-user --user-name dev`: Create 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 dev`: Generate access key for user

## Lambda (Serverless)

- `aws lambda list-functions`: List all Lambda functions
- `aws lambda invoke --function-name fn out.json`: Invoke a Lambda function
- `aws lambda get-function --function-name fn`: Show function configuration
- `aws lambda update-function-code --function-name fn --zip-file fileb://code.zip`: Deploy new function code
- `aws lambda list-event-source-mappings`: List event source triggers
- `aws logs tail /aws/lambda/fn --follow`: Tail Lambda CloudWatch logs

## ECS & ECR (Containers)

- `aws ecr get-login-password | docker login --username AWS --password-stdin <acct>.dkr.ecr.<region>.amazonaws.com`: Login to ECR registry
- `aws ecr describe-repositories`: List ECR repositories
- `aws ecs list-clusters`: List ECS clusters
- `aws ecs list-services --cluster my-cluster`: List services in cluster
- `aws ecs describe-services --cluster my-cluster --services my-svc`: Show service details
- `aws ecs update-service --cluster my-cluster --service my-svc --force-new-deployment`: Force new deployment

## CloudFormation & SSM

- `aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE`: List active stacks
- `aws cloudformation deploy --template-file tpl.yaml --stack-name my-stack`: Deploy/update a stack
- `aws cloudformation describe-stack-events --stack-name my-stack`: Show stack events
- `aws cloudformation delete-stack --stack-name my-stack`: Delete a stack
- `aws ssm get-parameter --name /app/db-password --with-decryption`: Get SSM parameter value
- `aws ssm put-parameter --name /app/key --value "val" --type SecureString`: Store encrypted parameter

## Common Flags & Output

- `--region us-west-2`: Override default region
- `--output json`: Output as JSON (default)
- `--output table`: Output as formatted table
- `--output text`: Output as tab-separated text
- `--query "Reservations[].Instances[].InstanceId"`: JMESPath query to filter output
- `--no-paginate`: Disable automatic pagination
- `--dry-run`: Check permissions without executing

## Sources

- `https://docs.aws.amazon.com/cli/latest/reference/`: AWS CLI v2 reference: service commands, parameters, profiles, and output options.

## Related

- Cheatsheet: [Docker Commands](https://findutils.com/cheatsheets/docker-commands/)
- Cheatsheet: [Kubernetes Commands](https://findutils.com/cheatsheets/kubernetes-commands/)
- Cheatsheet: [Apache HTTP Server](https://findutils.com/cheatsheets/apache-server/)
- Guide: [Cron Expression Generator: Build and Check Five-Field Schedules](https://findutils.com/guides/cron-expression-generator-guide/)
- Guide: [Yolobox Configurator: Generate AI Sandbox Configs in Seconds](https://findutils.com/guides/yolobox-ai-sandbox-configurator-guide/)
- Guide: [dnpm Guide: Isolate npm Commands with Docker](https://findutils.com/guides/dnpm-secure-docker-npm-wrapper-guide/)
