Building a cloud infrastructure using AWS CLI

AWS Logo


* AWS CLI SDK tool installed

aws --version

* AWS IAM user account

aws configure
Enter your IAM user credentials here

Creating a Key Pair

aws ec2 create-key-pair --key-name KeyPairCLi
aws ec2 create-key-pair --key-name KeyPairCli --query "KeyMaterial" > KeyPairCli.pem

Creating a Security Group

aws ec2 create-security-group --group-name MySgCLI --description=" Allow SSH Only " 
aws ec2 authorize-security-group-ingress --group-id sg-08f3e74b6f2d3d013 --protocol tcp --port 22 --cidr

Launching an instance using the above created key pair and security group.

aws ec2 run-instances     --security-group-ids sg-08f3e74b6f2d3d013            --instance-type    t2.micro   --image-id ami-052c08d70def0ac62  --key-name KeyPairCLi  --count 1

Creating an EBS Volume

aws ec2 create-volume --volume-type gp2 --size  1 --availability-zone ap-south-1a 
Availability Zone of our Instance

Attaching the EBS to our EC2 Instance

aws ec2  attach-volume   --volume-id vol-01d4376e6cb9bcad6  --instance-id i-0f1270420e4153203  --device sdf


aws ec2  detach-volume  --volume-id  vol-01d4376e6cb9bcad6
aws ec2 terminate-instances --instance-ids  i-0f1270420e4153203

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

Recommended from Medium

How To Install and Setup the Apache Web Server on Ubuntu 18.04

7 Easy Steps for Creating Your Own Web Scraper Using Python

View of the beach from inside a cave

UENC Project Weekly Report #80 (September 06, 2021 — September 11, 2021)

A Simple Guide to Making Websites with Bootstrap 4 (pt II) 🌑

2.5D Platformer — #13 Rolling

Visualizing Branch Dependencies with Google Sheets and the GitHub API

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
Piyush Mehta

Piyush Mehta

More from Medium

Create aTwitter Bot Using Dev-Ops Principles.

AWS access keys IP filtering protection

Docker A to Z

Building scalable and resilient applications using AWS