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/Option | Example | Description |
---|
aws configure | aws configure | Set up your AWS CLI with access key, secret key, region, and output format |
aws configure list | aws configure list | Display the current configuration settings |
aws configure set | aws configure set region us-west-2 | Set a specific configuration setting |
S3 (Simple Storage Service)
#
Command/Option | Example | Description |
---|
aws s3 ls | aws s3 ls | List all S3 buckets |
aws s3 mb | aws s3 mb s3://my-bucket | Create a new S3 bucket |
aws s3 rb | aws s3 rb s3://my-bucket | Delete an S3 bucket |
aws s3 cp | aws s3 cp file.txt s3://my-bucket/ | Copy a file to an S3 bucket |
aws s3 sync | aws s3 sync . s3://my-bucket | Synchronize a directory with an S3 bucket |
EC2 (Elastic Compute Cloud)
#
Command/Option | Example | Description |
---|
aws ec2 describe-instances | aws ec2 describe-instances | List all EC2 instances |
aws ec2 start-instances | aws ec2 start-instances --instance-ids i-1234567890abcdef0 | Start an EC2 instance |
aws ec2 stop-instances | aws ec2 stop-instances --instance-ids i-1234567890abcdef0 | Stop an EC2 instance |
aws ec2 terminate-instances | aws ec2 terminate-instances --instance-ids i-1234567890abcdef0 | Terminate an EC2 instance |
aws ec2 reboot-instances | aws ec2 reboot-instances --instance-ids i-1234567890abcdef0 | Reboot an EC2 instance |
IAM (Identity and Access Management)
#
Command/Option | Example | Description |
---|
aws iam create-user | aws iam create-user --user-name my-user | Create a new IAM user |
aws iam delete-user | aws iam delete-user --user-name my-user | Delete an IAM user |
aws iam list-users | aws iam list-users | List all IAM users |
aws iam create-role | aws iam create-role --role-name my-role --assume-role-policy-document file://policy.json | Create a new IAM role |
aws iam delete-role | aws iam delete-role --role-name my-role | Delete an IAM role |
Lambda
#
Command/Option | Example | Description |
---|
aws lambda create-function | aws 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.zip | Create a new Lambda function |
aws lambda delete-function | aws lambda delete-function --function-name my-function | Delete a Lambda function |
aws lambda invoke | aws lambda invoke --function-name my-function output.txt | Invoke a Lambda function |
aws lambda list-functions | aws lambda list-functions | List all Lambda functions |
Command/Option | Example | Description |
---|
aws cloudformation create-stack | aws cloudformation create-stack --stack-name my-stack --template-body file://template.json | Create a new CloudFormation stack |
aws cloudformation delete-stack | aws cloudformation delete-stack --stack-name my-stack | Delete a CloudFormation stack |
aws cloudformation describe-stacks | aws cloudformation describe-stacks | Describe CloudFormation stacks |
EKS (Elastic Kubernetes Service)
#
Command/Option | Example | Description |
---|
aws eks create-cluster | aws 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-12345678 | Create a new EKS cluster |
aws eks delete-cluster | aws eks delete-cluster --name my-cluster | Delete an EKS cluster |
aws eks list-clusters | aws eks list-clusters | List all EKS clusters |
CloudWatch
#
Command/Option | Example | Description |
---|
aws cloudwatch list-metrics | aws cloudwatch list-metrics | List CloudWatch metrics |
aws cloudwatch get-metric-data | aws cloudwatch get-metric-data --metric-data-queries file://queries.json | Retrieve CloudWatch metric data |
aws cloudwatch put-metric-data | aws cloudwatch put-metric-data --namespace MyNamespace --metric-name MyMetric --value 1.0 | Publish 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.