AWS CLI : intro

AWS command line interface is a tool to manage aws services through command line.

https://aws.amazon.com/cli/ : aws cli download

We commonly use aws using IAM user. After creating IAM user download credentials which are downloaded in .csv format.

After downloading aws cli and installing it open command prompt in windows or shell in linux.

To check whether aws cli installed or not run:

aws --version

To configure user in aws cli run :

aws configure

Put your downloaded credentials of user in output of above command to set that user in aws cli to manage services.

To check all metadata of ec2 instances we have:

aws ec2 describe-instances

To see volumes info for ec2 instances we have:

aws ec2 describe-volumes

For key related operations we have :

aws ec2 describe-key-pairs
aws ec2 describe-key-pairs --query KeyPairs
aws ec2 describe-key-pairs --query KeyPairs[0] #for 1st key pair
aws ec2 describe-key-pairs --query KeyPairs[0]."KeyName"
#to extract key name
aws ec2 create-key-pair --help

Instance Related Queries to pull out some specific info :

aws ec2 describe-instances
aws ec2 describe-instances --query Reservations[0].Instances[0]."PublicIpAddress"
aws ec2 describe-instances --query Reservations[0].Instances[1].["PublicIpAddress","KeyName"]
aws ec2 describe-instances --query Reservations[1].Instances[0].["PublicIpAddress","KeyName"]
aws ec2 describe-instances --query Reservations[*].Instances[0].["PublicIpAddress","KeyName","InstanceId","Tags"]
aws ec2 describe-instances --query Reservations[*].Instances[0].["PublicIpAddress","KeyName","InstanceId",Tags[*].Values]

Leave a comment

Design a site like this with WordPress.com
Get started