Using AWS CLI, Launch AWS instance and attach EBS Volume

In this article, let’s deep dive into AWS CLI or Command Line Interface

Prerequisites :

📌 Install the CLI Software of AWS in Linux,..

$ curl "" -o ""$unzip
$ sudo ./aws/install

You can go through the website for more detail… Click HERE

📌 After installing software, check

$ aws --version

You will see similar output …

📌 Now configure the aws in your system … For this, you need to create IAM user in your AWS account … First login to your account, And go to IAM Service. Now create a new user by clicking on “ Add User “

Download the credentials file into your system,..

📌 Now run the below command :

$ aws configure

Now copythe access key ID and secret access key from credentials file which u have downloaded and paste one by one into console output …

Creating Key-Pair …

$ aws ec2 create-key-pair - key-name cli-key - output text > cli-key.pem

U can also check using AWS web UI .

Creating Security group …

$ aws ec2 create-security-group --group-name task-cli --description allow-ssh-icmp

check using AWS web UI.

Now create rules which allows “SSH” and “ICMP”

$ aws ec2 authorize-security-group-ingress - group-name task-cli - protocol icmp - port -1 - cidr $ aws ec2 authorize-security-group-ingress - group-name task-cli - protocol tcp- port 22- cidr

check using AWS webUI .

Launching new instance…

$ aws ec2 run-instances \
> --instance-type <instance-type> \ # ex: t2.micro
> --image-id <image-id> \ # ex: ami-0e306788ff2473ccb
> --count 1 \
> --security-groups <name of the SG>\ # ex: task-cli
> --key-name <your key-name> # ex: cli-key

check using AWS web UI .

Creating EBS Volume…

$ aws ec2 create-volume \
> --volume-type gp2 \
> --size 1 \
> --availability-zone ap-south-1a

U will see the volume with available state .

Attaching EBS Volume

Now attach this EBS volume to the instance which we have created before,..

$ aws ec2 attach-volume \
> --volume-id <volume-id> \ # ex: vol-0e035469e737e8761
> --instance-id <instance-id> \ # ex: i-015c98656881da46b
> --device /dev/xvdh

U will see the EBS volume is attached to the instance .

That’s all for this article. If you find this useful please clap it.

Thanks for reading !!!

#AWSCSA #Arth #VimalDaga #Technologies#Awscloud #Awscli #AWS#Righteducation #Educationredefine #Rightmentor #Worldrecordholder #Linuxworld #MakingIndiaFutureReady #Righteducation #Arthbylw #AWSbyLW#Task3




Lifelong learning technologies

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to keep startup file lean and clean in Dotnet core

The DevRel Kerfluffle

Visual Studio Code + WSL: Running PHP Intellisense from Alpine Linux on Windows 10

Plena Finance partners with Biconomy to provide Plena users with hassle free blockchain interaction…

Plena Finance Partnership with Biconomy

The Total Cost of Running and Maintaining an App

How to simulate different network conditions for your mobile app

How to get Started with flutter?(Installation Guide for windows x64)

9 Flutter Apps That Protect Your Privacy

Person holding phone, leaves sprouting out of where their head would be

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
Arnab Saha

Arnab Saha

Lifelong learning technologies

More from Medium

Automatically tag AWS EC2 Instances with the “Owner” tag upon creation

Installing and Configuring AWS CLI with Multiple profiles

How to Securely Share Files within AWS without a login

How to host a static website on AWS with S3, CloudFront, Route53 and Terraform — Interweave