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.

The AWS CLI V2 offers several new features including improved installers, new configuration options such as AWS Single Sign-On (SSO), and various interactive features.

For login through AWS CLI we need to provide secrete key and access key. IAM is the service provided by AWS which can create these both the things

Adding IAM user:

AWS version checking:

configuring AWS in CLI mode:

creation of Key Pair using command:

aws ec2 create-key-pair — key-name cli_key_pair

Command for creating key pair:

#aws ec2 create-key-pair — key-name cli_key_pair

In GUI mode we can see key pair created:

Creation of Security Group:

copy the VPC id from VPC services:

Command for creating security group:

#aws ec2 create-security-group — group-name mySG — description “My Security Group”

In GUI we can see SG is created:

Creating an instance from CLI mode of AWS:

Take Amazon Linux 2 AMI through GUI:

Command for creating Instance in EC2:

#aws ec2 run-instances — image-id ami-0e306788ff2473ccb — instance-type t2.micro — subnet-id subnet-22353e4a — security-group-ids sg-090840afd4cd41652 — key-name cli_key_pair — count 1

Create EBS volume of 1 GB:

Command for creating EBS volume:

#aws ec2 create-volume — avaliability-zone ap-south-1a — size 1

Here you will see that EBS volume of size 1 GB has been created:

Finally we can attach this EBS volume of 1 GB to Instance which we have already created. For attaching we need to provide root device name, instance id and volume id:

Command for attaching EBS volume to Instance:

#aws ec2 attach-volume — device /dev/sda1 — instance-id i-091e7c6b3c91753c3 — volume-id vol-0f16568563b64cffc

Thanks for reading!! :)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store