AWS CLI

AWS CLI Cheatsheet #

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

Configuration #

Command/OptionExampleDescription
aws configureaws configureSet up your AWS CLI with access key, secret key, region, and output format
aws configure listaws configure listDisplay the current configuration settings
aws configure setaws configure set region us-west-2Set a specific configuration setting

S3 (Simple Storage Service) #

Command/OptionExampleDescription
aws s3 lsaws s3 lsList all S3 buckets
aws s3 mbaws s3 mb s3://my-bucketCreate a new S3 bucket
aws s3 rbaws s3 rb s3://my-bucketDelete an S3 bucket
aws s3 cpaws s3 cp file.txt s3://my-bucket/Copy a file to an S3 bucket
aws s3 syncaws s3 sync . s3://my-bucketSynchronize a directory with an S3 bucket

EC2 (Elastic Compute Cloud) #

Command/OptionExampleDescription
aws ec2 describe-instancesaws ec2 describe-instancesList all EC2 instances
aws ec2 start-instancesaws ec2 start-instances --instance-ids i-1234567890abcdef0Start an EC2 instance
aws ec2 stop-instancesaws ec2 stop-instances --instance-ids i-1234567890abcdef0Stop an EC2 instance
aws ec2 terminate-instancesaws ec2 terminate-instances --instance-ids i-1234567890abcdef0Terminate an EC2 instance
aws ec2 reboot-instancesaws ec2 reboot-instances --instance-ids i-1234567890abcdef0Reboot an EC2 instance

IAM (Identity and Access Management) #

Command/OptionExampleDescription
aws iam create-useraws iam create-user --user-name my-userCreate a new IAM user
aws iam delete-useraws iam delete-user --user-name my-userDelete an IAM user
aws iam list-usersaws iam list-usersList all IAM users
aws iam create-roleaws iam create-role --role-name my-role --assume-role-policy-document file://policy.jsonCreate a new IAM role
aws iam delete-roleaws iam delete-role --role-name my-roleDelete an IAM role

Lambda #

Command/OptionExampleDescription
aws lambda create-functionaws lambda create-function --function-name my-function --runtime python3.8 --role arn:aws:iam::account-id:role/execution_role --handler lambda_function.lambda_handler --zip-file fileb://function.zipCreate a new Lambda function
aws lambda delete-functionaws lambda delete-function --function-name my-functionDelete a Lambda function
aws lambda invokeaws lambda invoke --function-name my-function output.txtInvoke a Lambda function
aws lambda list-functionsaws lambda list-functionsList all Lambda functions

CloudFormation #

Command/OptionExampleDescription
aws cloudformation create-stackaws cloudformation create-stack --stack-name my-stack --template-body file://template.jsonCreate a new CloudFormation stack
aws cloudformation delete-stackaws cloudformation delete-stack --stack-name my-stackDelete a CloudFormation stack
aws cloudformation describe-stacksaws cloudformation describe-stacksDescribe CloudFormation stacks

EKS (Elastic Kubernetes Service) #

Command/OptionExampleDescription
aws eks create-clusteraws eks create-cluster --name my-cluster --role-arn arn:aws:iam::account-id:role/eksServiceRole --resources-vpc-config subnetIds=subnet-12345678,subnet-87654321,securityGroupIds=sg-12345678Create a new EKS cluster
aws eks delete-clusteraws eks delete-cluster --name my-clusterDelete an EKS cluster
aws eks list-clustersaws eks list-clustersList all EKS clusters

CloudWatch #

Command/OptionExampleDescription
aws cloudwatch list-metricsaws cloudwatch list-metricsList CloudWatch metrics
aws cloudwatch get-metric-dataaws cloudwatch get-metric-data --metric-data-queries file://queries.jsonRetrieve CloudWatch metric data
aws cloudwatch put-metric-dataaws cloudwatch put-metric-data --namespace MyNamespace --metric-name MyMetric --value 1.0Publish a metric to CloudWatch

This cheatsheet covers the most commonly used AWS CLI commands and options, helping you to manage S3, EC2, IAM, Lambda, CloudFormation, EKS, CloudWatch, and more effectively.

AWS CLI

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.