Building Basic AWS Cloud Infrastructure Using AWS CLI

Rohitbhatt
4 min readOct 16, 2020

--

By the End of this Blog, you come to know about the following things:

đź”· Create a new 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.

So to use and manage the AWS services using Command Line Interface (CLI) we have to Install the software i.e. AWS CLI version 2 you can download this from here: https://awscli.amazonaws.com/AWSCLIV2.msi

Step 1: Create an IAM user from AWS WebUI

we need to create a user from the IAM service provided by the AWS in which we need to give permission “PowerUserAccess”.

Now From here, we get an Access Key ID and Secret Access Key to login with CLI and now Steps to configure your AWS CLI:

🔷 Open your terminal in the system and type “aws configure” command.

đź”· Fill all the details in it and your AWS CLI will start working.

Step 2: Create a new key pair.

we can create a new key pair by using the following command:

aws ec2 create-key-pair — key-name keyusingcli using this command we successfully created our Key-Pair.

Step3: Create a security group.

we can create a security group by using the following command:

aws ec2 create-security-group — group-name securityCLI — description “creating security group from CLI”

Now let us check from GUI of AWS that our security group is created or not.

Step 4: Launch an instance using the above created key pair and security group.

we can launch a instance by following command:-

aws ec2 run-instances — image-id ami-0e306788ff2473ccb — instance-type t2.micro — count 1 security-group-ids sg-00ca71bc9b2a10d20 — key-name awsclikey.

Now let us check Our Instance is launch or not from AWS GUI

Till now we successfully launch a instance from AWS CLI.

Step 5: Create an EBS volume of 1 GB

To create an EBS volume of 1GB we use the following command:-

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

Now let us check Our volume is created or not from AWS GUI.

Step 6:Now ,we have to Attach the above created EBS volume to our instance.

To attach EBS volume to our instance we use the following command:-

aws ec2 attach-volume — volume-id vol-00cceb2d0d23032b7 — instance-id i-057cab665ff4929c9 — device /dev/xvdh.

now let’s check from AWS GUI that our volume is attached or not.

Great, you successfully attach your EBS volume to the instance.

I hope you like this blog.

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

www.linkedin.com/in/rohit-bhatt-97499b188.

Thank you!!!!!!!!!

--

--

No responses yet