AWS CLI Cheat Sheet
Table of Contents:
Pro Tip!
If you have multiple AWS Accounts, you can use bash alias like the following. So you no longer need to pass --profile to aws tool.
To format aws command output into tables, you can pipe output to column -t.
EC2
List Instance ID, Type and Name
List Instances with Public IP Address and Name
Tip: You can directly put this to your /etc/hosts
List Instances with Tag
List of VPCs and CIDR IP Block
List of Subnets for a VPC
List of Security Groups
Print Security Groups for an Instance
Edit Security Groups of an Instance
You have to provide existing Security Group IDs as well
Print Security Group Rules as FromAddress and ToPort
Add Rule to Security Group
Delete Rule from Security Group
Edit Rules of Security Group
You have to provide All IP Ranges as well
Delete Security Group
ACM
List Certificate ARNs and DomainName
S3
List Buckets
List Files in a Bucket
Create Bucket
Delete Bucket
Download S3 Object to Local
Upload Local File as S3 Object
Delete S3 Object
Download Bucket to Local
Upload Local Directory to Bucket
Share S3 Object without Public Access
API Gateway
List of API Gateway IDs and Names
List of API Gateway Keys
List API Gateway Domain Names
List of Resources for API Gateway
Find Lambda for API Gateway Resource
ELB
Create ALB
Create Target Group forwarding to port HTTP/8000 of an EC2
Create Listener and Bind Target Group
Now the DNSName of the LoadBalancer should respond to the same output producted by application running on port 8000 of the EC2.
Create HTTPS Listener with Host Based Rule
List of LoadBalancer Hostnames
List of LoadBalancer ARNs
List of Target Group ARNs
Find Instances for a Target Group
RDS
List of DB Clusters
List of DB Instances
Take DB Instance Snapshot
Take DB Cluster Snapshot
ElastiCache
List of ElastiCache Machine Type and Name
List of ElastiCache Replication Groups
List of ElastiCache Snapshots
Create ElastiCache Snapshot
Delete ElastiCache Snapshot
Scale Up/Down ElastiCache Replica
Lambda
List of Lambda Functions, Runtime and Memory
List of Lambda Layers
List of Source Event for Lambda
Download Lambda Code
Cloudwatch
List of CloudWatch Alarms and Status
Create Alarm for EC2 High CPUUtilization
Create Alarm for EC2 High StatusCheckFailed_Instance
Route53
List Domains
List Records for a Domain (Zone)
SNS
List of SNS Topics
List of SNS Topic and related Subscriptions
Publish to SNS Topic
DynamoDB
List of DynamoDB Tables
Get All Items from a Table
:exclamation: This command will stream ALL items untill SIGINT is sent
Get Item Count from a Table
Get Item using Key
Get Specific Fields from an Item
Delete Item using Key
SQS
List Queues
Create Queue
Count Messages in Queue
Send Message
Receive Message
Delete Message
Purge Queue
Delete Queue
CloudFront
List of CloudFront Distributions and Origins
Create Cache Invalidation
Check Cache Invalidation Status
Amplify
List of Amplify Apps and Source Repository
Cognito
List of User Pool IDs and Names
List of Phone and Email of All Users
EFS
List of Filesystems
ECR
List of Repositories
List Tags under a Repository
EKS
List of Clusters
Generate KUBECONFIG for Cluster
IAM User
List of UserId and UserName
Get Single User
Add User
Delete User
List Access Keys for User
Delete Access Key for User
Activate/Deactivate Access Key for User
Generate New Access Key for User
IAM Group
List Groups
Add/Delete Groups
List of Policies and ARNs
List of User/Group/Roles for a Policy
List Policies for a Group
Add Policy to a Group
Add User to a Group
Remove User from a Group
List Users in a Group
List Groups for a User
Attach/Detach Policy to a Group