How to install and use AWS using CLI

AWS provides one of the best cloud services. Apart from many features it also lets their user use Amazon Services through WebUI as well as CLI.
In this blog, we are going to see how we can use these services through CLI.
For this, we have to install the CLI software for windows. You can install it using this link https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi
AWS provides a variety of commands to use nearly all its features. It also provides the list of all its commands and subcommands. And gives a brief description of it.

1. AWS EC2
creating an EC2 instance

aws ec2 run-instances — image-id ami-0947d2ba12ee1ff75 — count 1 — instance-type t2.micro — key-name gauravkey
This command creates an EC2 instance of Amazon Linux as OS, t2.micro as instance type, and with the key named gauravkey.
After creating the instance it shows the instance in the json format as a success.
displaying all the instances

aws ec2 describe-instances
This command displays all the instances in the AWS. It also has subcommands to filter the results like:
[ — filters <value>]
[ — instance-ids <value>]
[ — starting-token <value>]
[ — page-size <value>]
etc.
2. Key Pairs
generating key pairs
aws ec2 create-key-pair — key-name test — query ‘KeyMaterial’ — output text > test.pem
This command creates a key pair, key-name test and converts it into the .pem file and saves with the name test.pem.
apart form that we can also add the tags to the generated key with the help of the syntax
[ — tag-specifications <value>]
displaying key pairs

aws ec2 describe-key-pairs — key-name gauravkey
This command displays all the instances in the AWS with their ids, fingerprints, and tags (if any).
3. EBS Volume
creating a volume

aws ec2 create-volume — size 1 — availability-zone us-east-1d
This command creates an EBS volume in us-east-1d i.e. in the Availability Zone of North Virginia region.
showing all the volumes

aws ec2 describe-volumes
This command displays all the EBS volumes created.We can also filter the results using :
[ — filters <value>]
[ — volume-ids <value>]
[ — dry-run | — no-dry-run]
[ — max-items <value>]
[ — cli-auto-prompt <value>]
attaching the EBS
aws ec2 attach-volume — volume-id vol-02e8f46b8e8253b87 — instance-id i-06bcbcbee4dae1ba9 — device /dev/sdf

This command attaches the EBS with volumeId: “vol-02e8f46b8e8253b87” to the instance with InstanceId: “i-06bcbcbee4dae1ba9”.
detaching the EBS
aws ec2 detach-volume — volume-id vol-02e8f46b8e8253b87

This command detaches the EBS with volumeId: “vol-02e8f46b8e8253b87”.
These commands automatically display the result in our CLI but if we want we can also confirm them by going to the WebUI of AWS.
This blog contains very limited commands if you want you can go to the AWS Documentation and explore more commands.