Common commands
General Configuration
-
Configure AWS CLI with credentials: aws configure –> Enter Access Key, Secret Key, Region, and Output Format.
-
Create a profile: aws configure –profile <profile-name>
-
Use a specific profile: Add –profile <profile-name> to your commands.
S3 (Simple Storage Service)
-
List all buckets: aws s3 ls
-
Create a bucket: aws s3 mb s3://<bucket-name>
-
Delete a bucket: aws s3 rb s3://<bucket-name> –force
-
Upload a file: aws s3 cp <file-path> s3://<bucket-name>
-
Download a file: aws s3 cp s3://<bucket-name>/<file-name> <destination-path>
-
Sync a local directory to a bucket: aws s3 sync <local-directory> s3://<bucket-name>
EC2 (Elastic Compute Cloud)
-
List instances: aws ec2 describe-instances
-
Start an instance: aws ec2 start-instances –instance-ids <instance-id>
-
Stop an instance: aws ec2 stop-instances –instance-ids <instance-id>
-
Terminate an instance: aws ec2 terminate-instances –instance-ids <instance-id>
-
List security groups: aws ec2 describe-security-groups
IAM (Identity and Access Management)
-
List users: aws iam list-users
-
Create a user: aws iam create-user –user-name <user-name>
-
Delete a user: aws iam delete-user –user-name <user-name>
-
Attach a policy to a user: aws iam attach-user-policy –user-name <user-name> –policy-arn <policy-arn>
-
List groups: aws iam list-groups
CloudWatch
-
List alarms: aws cloudwatch describe-alarms
-
Delete an alarm: aws cloudwatch delete-alarms –alarm-names <alarm-name>
Lambda
-
List Lambda functions: aws lambda list-functions
-
Invoke a function: aws lambda invoke –function-name <function-name> <output-file>
-
Delete a function: aws lambda delete-function –function-name <function-name>
Route53
-
List hosted zones: aws route53 list-hosted-zones
-
Create a hosted zone: aws route53 create-hosted-zone –name <domain-name>
-
Delete a hosted zone: aws route53 delete-hosted-zone –id <zone-id>
SNS (Simple Notification Service)
-
List topics: aws sns list-topics
-
Publish a message: aws sns publish –topic-arn <topic-arn> –message “<message>”
-
Subscribe to a topic: aws sns subscribe –topic-arn <topic-arn> –protocol <protocol> –notification-endpoint <endpoint>
DynamoDB
-
List tables: aws dynamodb list-tables
-
Describe a table: aws dynamodb describe-table –table-name <table-name>
-
Delete a table: aws dynamodb delete-table –table-name <table-name>
EKS (Elastic Kubernetes Service)
-
List clusters: aws eks list-clusters
-
Describe a cluster: aws eks describe-cluster –name <cluster-name>
-
Delete a cluster: aws eks delete-cluster –name <cluster-name>
References
[1] https://docs.aws.amazon.com/cli/latest/
[2] https://www.bluematador.com/learn/aws-cli-cheatsheet
[3] https://gist.github.com/apolloclark/b3f60c1f68aa972d324b
[4] https://dataguymichael.substack.com/p/the-ultimate-aws-cli-cheat-sheet
