Creating AWS Infrastructure Using AWS CLI

Abhishek Chouhan
5 min readMar 6, 2021

--

Hey All Cloud Enthusiast’s…

Today I am going to explain you about AWS CLI and how to launch an instance on AWS Cloud Using it.

Created By Me

Task Description → AWS

✔ Create a key pair
✔ Create a security group
✔ Launch an instance using the above created key pair and security group.
✔ Create an EBS volume of 1 GB.
✔ The final step is to attach the above created EBS volume to the instance you created in the previous steps.
All the above steps must be performed using AWS CLI .
Source :- Google

Amazon Web Services (AWS) is a subsidiary of Amazon providing on-demand cloud computing platforms and APIs to individuals, companies, and governments, on a metered pay-as-you-go basis. These cloud computing web services provide a variety of basic abstract technical infrastructure and distributed computing building blocks and tools. One of these services is Amazon Elastic Compute Cloud (EC2), which allows users to have at their disposal a virtual cluster of computers, available all the time, through the Internet. AWS’s version of virtual computers emulates most of the attributes of a real computer, including hardware central processing units (CPUs) and graphics processing units (GPUs) for processing; local/RAM memory; hard-disk/SSD storage; a choice of operating systems; networking; and pre-loaded application software such as web servers, databases, and customer relationship management (CRM).

Pre-requisites :-

. AWS Account

. IAM User in that AWS account.

. AWS CLI must be installed

. some other pre-requisites may require that i will be explaining in betweeen.

So Let’s Start 🤟…

Create IAM User

Source :- AWS Console

after that click on users

Source :- AWS Console

and then click on add user

Source :- AWS Console

just give some name and select programmatic access option .

Source :- AWS Console

for giving permission choose third option i.e. attach existing policies directly . tick the AdministratorAccess option …

Source :- AWS Console

then just click next…. and IAM user with admin power will be created for you they will provide you some credentials like access key and secret key for using AWS cloud form CLI .

i.e. by using aws configure command we will complete the same

aws configure
aws configure

Now from here we can start our practical …

🗝Command to create credential and key pair

aws ec2 create-key-pair — key-name Abhikey1122
Creating key

We can check it from cli that key is created .

Source :- AWS Console

And for creating security group

Command →

aws ec2 create-security-group — group-name Abhi_SG — vpc-id vpc-c8879aa0 — description “Abhi Security Group Created From CLI”

Again we can check security group is created ..

Source :- AWS Console

Details required for launching AWS instance from AWS CLI .

Command to launch an AWS instance →

aws ec2 run-instances — image-id ami-0e306788ff2473ccb — instance-type t2.micro — count 1 — subnet-id subnet-5b4c2717 — security-group-ids sg-07220bbbfe36adb85 — key-name Abhikey1122

Instance has been launched

Source :- AWS Console

Now time to create volume so that we can attach it to the instance

aws ec2 create-volume — volume-type gp2 — availability-zone ap-south-1b — size 1

Error u might face during attaching

error you might face during attaching a volume to the instance

So do this…

Source :- AWS Console

Volume that we created is now attached in the instance .

Source :- AWS Console

That’s all our task is done and we have launched an instance on AWS and then after creating a new volume we have attached with it ….

Few Last words .

→ There Are Many things about AWS Cloud that i will be discussing in my upcoming article .

→ I will be sharing many article’s on Integrating multiple tools and technologies Cloud Computing, DevOps, Big Data Hadoop, Machine Learning etc. In Upcoming days .

→ Follow me on Medium for more Article’s on Research based and integration of new new tools and technologies .

For Furthur Queries, Suggestion’s Feel Free to Connect with me On Linkedin .

I Hope you learned something new from this article .

If you like it then Clap & Share ..

Thank you EveryOne For Reading …..

--

--

Abhishek Chouhan

Technology Enthusiast Like to learn new new tools and technology and integrate them, DevOps, Cloud, MLOps, Kubernetes, AWS, Terraform, Expertise in Docker…