Here’s a comprehensive list of AWS CLI commands categorized by their functionality.
-
Configure AWS CLI:
aws configure
-
Get AWS CLI version:
aws --version
-
List all instances:
aws ec2 describe-instances
-
Start an instance:
aws ec2 start-instances --instance-ids i-1234567890abcdef0
-
Stop an instance:
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
-
Terminate an instance:
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0
-
Create an AMI (Amazon Machine Image):
aws ec2 create-image --instance-id i-1234567890abcdef0 --name "My server" --no-reboot
-
Describe instance types:
aws ec2 describe-instance-types
-
List all security groups:
aws ec2 describe-security-groups
-
List all S3 buckets:
aws s3 ls
-
Create a new S3 bucket:
aws s3 mb s3://my-bucket
-
Upload a file to an S3 bucket:
aws s3 cp localfile.txt s3://my-bucket/
-
Download a file from an S3 bucket:
aws s3 cp s3://my-bucket/remotefile.txt .
-
Sync a local directory with an S3 bucket:
aws s3 sync localdir/ s3://my-bucket/
-
Delete a file from an S3 bucket:
aws s3 rm s3://my-bucket/remotefile.txt
-
List IAM users:
aws iam list-users
-
Create a new IAM user:
aws iam create-user --user-name newuser
-
Delete an IAM user:
aws iam delete-user --user-name olduser
-
Attach a policy to a user:
aws iam attach-user-policy --user-name username --policy-arn arn:aws:iam::aws:policy/PolicyName
-
List IAM roles:
aws iam list-roles
-
Create a new IAM role:
aws iam create-role --role-name newrole --assume-role-policy-document file://trust-policy.json
-
List all RDS instances:
aws rds describe-db-instances
-
Start an RDS instance:
aws rds start-db-instance --db-instance-identifier mydbinstance
-
Stop an RDS instance:
aws rds stop-db-instance --db-instance-identifier mydbinstance
-
Create a new RDS instance:
aws rds create-db-instance --db-instance-identifier mydbinstance --db-instance-class db.t2.micro --engine mysql --allocated-storage 20
-
Delete an RDS instance:
aws rds delete-db-instance --db-instance-identifier mydbinstance --skip-final-snapshot
-
List all VPCs:
aws ec2 describe-vpcs
-
Create a new VPC:
aws ec2 create-vpc --cidr-block 10.0.0.0/16
-
Delete a VPC:
aws ec2 delete-vpc --vpc-id vpc-12345678
-
List all subnets:
aws ec2 describe-subnets
-
Create a new subnet:
aws ec2 create-subnet --vpc-id vpc-12345678 --cidr-block 10.0.1.0/24
-
Delete a subnet:
aws ec2 delete-subnet --subnet-id subnet-12345678
-
List all stacks:
aws cloudformation list-stacks
-
Create a new stack:
aws cloudformation create-stack --stack-name mystack --template-body file://template.json
-
Update a stack:
aws cloudformation update-stack --stack-name mystack --template-body file://template.json
-
Delete a stack:
aws cloudformation delete-stack --stack-name mystack
-
List all CloudWatch alarms:
aws cloudwatch describe-alarms
-
Create a CloudWatch alarm:
aws cloudwatch put-metric-alarm --alarm-name myalarm --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 60 --threshold 80 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --alarm-actions arn:aws:sns:us-east-1:123456789012:mytopic
-
Delete a CloudWatch alarm:
aws cloudwatch delete-alarms --alarm-names myalarm
-
List all hosted zones:
aws route53 list-hosted-zones
-
Create a new hosted zone:
aws route53 create-hosted-zone --name example.com --caller-reference unique-string
-
Delete a hosted zone:
aws route53 delete-hosted-zone --id Z1234567890ABC
-
List all records in a hosted zone:
aws route53 list-resource-record-sets --hosted-zone-id Z1234567890ABC
-
List all SQS queues:
aws sqs list-queues
-
Create a new SQS queue:
aws sqs create-queue --queue-name myqueue
-
Delete an SQS queue:
aws sqs delete-queue --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/myqueue
-
Send a message to an SQS queue:
aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/myqueue --message-body "Hello World"
-
Receive messages from an SQS queue:
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/myqueue
-
List all SNS topics:
aws sns list-topics
-
Create a new SNS topic:
aws sns create-topic --name mytopic
-
Delete an SNS topic:
aws sns delete-topic --topic-arn arn:aws:sns:us-east-1:123456789012:mytopic
-
Publish a message to an SNS topic:
aws sns publish --topic-arn arn:aws:sns:us-east-1:123456789012:mytopic --message "Hello World"
-
List all Lambda functions:
aws lambda list-functions
-
Create a new Lambda function:
aws lambda create-function --function-name myfunction --zip-file fileb://function.zip --handler index.handler --runtime nodejs14.x --role arn:aws:iam::123456789012:role/execution_role
-
Invoke a Lambda function:
aws lambda invoke --function-name myfunction outputfile.txt
-
Delete a Lambda function:
aws lambda delete-function --function-name myfunction
This list includes essential AWS CLI commands for managing various AWS services. It should provide a solid foundation for working with AWS resources.