What’s the AWS CLI?

Command line API

  • A tool that enables you to interact with AWS services using commands in your command-line shell.

  • Direct access to the public APIs of AWS services

  • You can develop scripts to manage your resources.

  • It’s open-source https://github.com/aws/aws-cli.

  • Alternative to using AWS Management Console

Cheat Sheet + Tips and Tricks

If you haven't installed AWS CLI yet start at the Installing the AWS CLI Guide from Amazonarrow-up-right.

Pro-tip 1 - use the command-completion feature.

We think the best cheatsheet you can have for AWS CLI is the command-completion feature. It allows you to use the Tab key to complete a partially entered command. It will either complete your command or display a list of suggested commands. It isn't always automatically installed, so you'll need to configure it manually. Here is the AWS guidearrow-up-right to get it up and running.

Pro-tip 2 - use the help command.

When you need a little extra help just lean on the AWS CLI help command to get detailed documentation on what is available. To use this command you just append help at the end of a command name. For example, if you do 'aws help' it will show the general AWS CLI options and list all the services. If you need to see what all the available commands for AWS EC2 specifically, you would type 'aws ec2 help.' It will become a huge aid to you in becoming an AWS CLI pro.

Pro-tip 3 - use jq.

This cheat sheet utilizes jq, a lightweight and flexible command-line JSON processor. We highly recommend using it for AWS CLI. You can find more information on it at the Github repository for itarrow-up-right.

Config

Create profiles

Output format

Specify your AWS Region

API Gateway

List API Gateway IDs and Names

List API Gateway keys

List API Gateway domain names

List resources for API Gateway

Find Lambda for API Gateway resource

Amplify

List Amplify apps and source repository

CloudFront

List CloudFront distributions and origins

Create a new invalidation

CloudWatch

List information about an alarm

Delete an alarm or alarms (you can delete up to 100 at a time)

Cognito

List user pool IDs and names

List phone and email of all users

DynamoDB

List DynamoDB tables

Get all items from a table

Get item count from a table

Get item using key

Get specific fields from an item

Delete item using key

EBS

Complete a Snapshot

Start a Snapshot

Get a Snapshot block

EC2

List Instance ID, Type and Name

List Instances with public IP address and Name

List VPCs and CIDR IP Block

List Subnets for a VPC

List Security Groups

Print Security Groups for an Instance

Edit Security Groups of an Instance

Print Security Group Rules as FromAddress and ToPort

Add Rule to Security Group

Delete Rule from Security Group

Edit Rules of Security Group

Delete Security Group

ECS

Create an ECS cluster

Create an ECS service

EKS

Create a cluster

Delete a cluster

List descriptive information about a cluster

List clusters in your default region

Tag a resource

Untag a resource

ElastiCache

Get information about a specific cache cluster

List ElastiCache replication groups

List ElastiCache snapshots

Create ElastiCache snapshot

Delete ElastiCache snapshot

Scale up/down ElastiCache replica

ELB

List ELB Hostnames

List ELB ARNs

List of ELB target group ARNs

Find instances for a target group

IAM Group

List groups

Add/Delete groups

List policies and ARNs

List 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

IAM User

List 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

Lambda

List Lambda functions, runtime, and memory

List Lambda layers

List source event for Lambda

Download Lambda code

RDS

List DB clusters

List DB instances

Take DB Instance Snapshot

Take DB cluster snapshot

Route53

Create hosted zone

Delete hosted zone

Get hosted zone

List hosted zones

Create a record set

To do this you’ll first need to create a JSON file with a list of change items in the body and use the CREATE action. For example the JSON file would look like this.

Once you have a JSON file with the correct information like above you will be able to enter the command

Update a record set

To do this you’ll first need to create a JSON file with a list of change items in the body and use the UPSERT action. This will either create a new record set with the specified value, or updates a record set if it already exists. For example the JSON file would look like this.

Once you have a JSON file with the correct information like above you will be able to enter the command

Delete a record set

To do this you’ll first need to create a JSON file with a list of the record set values you want to delete in the body and use the DELETE action. For example the JSON file would look like this.

Once you have a JSON file with the correct information like above you will be able to enter the following command.

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

SNS

List SNS topics

List SNS topic and related subscriptions

Publish to SNS topic

SQS

List queues

Create queue

Send message

Receive message

Delete message

Purge queue

Delete queue

Last updated