AWS CLI – Cheat Sheet

AWS CLI Documentation
CLI User Guide
CLI Reference

IAM

AWS CLI CommandDescription
aws iam list-usersList IAM users
aws iam create-user --user-name my-userCreate an IAM user
aws iam delete-user --user-name my-userDelete an IAM user
aws iam create-access-key --user-name my-userCreate an access key for an IAM user
aws iam delete-access-key --user-name my-user --access-key-id AKIAIOSFODNN7EXAMPLEDelete an access key for an IAM user
aws iam list-groupsList IAM groups
aws iam create-group --group-name my-groupCreate an IAM group
aws iam delete-group --group-name my-groupDelete an IAM group
aws iam add-user-to-group --user-name my-user --group-name my-groupAdd an IAM user to an IAM group
aws iam remove-user-from-group --user-name my-user --group-name my-groupRemove an IAM user from an IAM group
aws iam list-policiesList IAM policies
aws iam create-policy --policy-name my-policy --policy-document file://my-policy.jsonCreate an IAM policy

S3

These commands can be used to list and retrieve information about S3 buckets, such as their contents, access control lists, policies, versioning, encryption, and logging settings.

AWS CLI CommandDescription
aws s3 lsList all S3 buckets
aws s3 ls s3://bucket-nameList contents of a specific S3 bucket
aws s3api get-bucket-acl --bucket bucket-nameGet the access control list (ACL) for an S3 bucket
aws s3api get-bucket-policy --bucket bucket-nameGet the bucket policy for an S3 bucket
aws s3api get-bucket-versioning --bucket bucket-nameGet the versioning state for an S3 bucket
aws s3api get-bucket-encryption --bucket bucket-nameGet the encryption state for an S3 bucket
aws s3api get-bucket-logging --bucket bucket-nameGet the logging state for an S3 bucket
aws s3api list-objects --bucket bucket-nameList objects in an S3 bucket
aws s3api head-object --bucket bucket-name --key key-nameGet information about an object in an S3 bucket (e.g. size, storage class, etc.)

EC2

The EC2 command list below is useful for managing EC2-related AWS resources. It can be used to list, start, stop, reboot, and terminate EC2 instances, as well as create and launch new instances from Amazon Machine Images (AMIs). These commands are also useful for managing EC2 security groups and adding ingress rules.

AWS CLI CommandDescription
aws ec2 describe-instancesList EC2 instances
aws ec2 describe-instances --instance-ids i-1234567890abcdef0Get details for a specific EC2 instance
aws ec2 start-instances --instance-ids i-1234567890abcdef0Start an EC2 instance
aws ec2 stop-instances --instance-ids i-1234567890abcdef0Stop an EC2 instance
aws ec2 reboot-instances --instance-ids i-1234567890abcdef0Reboot an EC2 instance
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0Terminate an EC2 instance
aws ec2 describe-images --owners amazonList Amazon Machine Images (AMIs)
aws ec2 create-image --instance-id i-1234567890abcdef0 --name "My AMI"Create an AMI from an EC2 instance
aws ec2 run-instances --image-id ami-1234567890abcdef0 --count 1 --instance-type t2.microLaunch an EC2 instance from an AMI
aws ec2 describe-security-groupsList EC2 security groups
aws ec2 create-security-group --group-name my-sg --description "My security group"Create an EC2 security group
aws ec2 authorize-security-group-ingress --group-name my-sg --protocol tcp --port 22 --cidr 0.0.0.0/0Add an ingress rule to an EC2 security group

Glue


RedShift