Building Cloud Infrastructure using AWS CLI

 

This article will help us to know How to Build Cloud Infrastructure using AWS  CLI.


Before dive into the practical part let's understand some basic terminology it will help you for a better understanding of the further part So, Let's get started....


What is AWS ??πŸ€”


        

            Amazon Web Services (AWSoffers a broad set of global cloud-based products, including compute, storage, databases, networking, analytics,  mobile, developer tools, management tools, Internet of Things (IoT), security, enterprise applications and many more with a pay-as-you-go pricing model.


πŸ”°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.


NOTE: All the above steps must be performed using AWS CLI


Prerequisites:

  • AWS Account
  • AWS CLI Application
  • IAM User Configuration with AWS CLI
Install AWS CLI : AWS CLI VERSION2


What is AWS  CLI ??πŸ€”


          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.




To use the AWS Command Line Tool, first we need to Configure Access ID & Secret Key With the help of  Identity Access Management ( IAM ) service of  AWS.


  • Create IAM User With Root User :
Click on IAM and then Users








Click on Add User 




Add user name & Access Type




Select permission




Review





After successfully user creation  we get  a Access key ID and Secret key by using these security credentials we can login to AWS CLI easily.


  • Configure AWS CLI
command:
$ aws configure


Now we Successfully logged-In to AWS CLI.



πŸ”… Step - 1 : Create a key pair


command:
$ aws ec2 create-key-pair --key-name awstaskkey





We can see the output on Managemnet Console:


 




πŸ”… Step - 2 : Create a security group


command:
$  aws ec2 create-security-group --group-name mysecgrp --description "this is my sg"









New Security Group is successfully created !!


πŸ”… Step - 3 : Launch an instance using the above created key pair and security group


command:

aws ec2 run-instances 
--image-id ami-026669ec456129a70
--instance-type t2.micro
--count 1
--subnet-id subnet-bc7709f0
--security-group-ids sg-0c13ee07713841076
--key-name awstaskkey



















πŸ”… Step - 4 : Create an EBS volume of 1 GB

command :
$  aws ec2 create-volume --volume-type gp2 --size 1  --availability-zone ap-south-1b









πŸ”… Step - 5 : The final step is to attach the above created EBS volume to the instance you created in the previous steps

An Amazon EBS volume is a block-level storage device that you can attach to your instances. After attaching volume to an instance,  you can use it as you would use a physical hard drive.

command :

$ aws ec2 attach-volume --volume-id vol-0cd1777c28baad8b5  --instance-id i-0b20ef877ca5e07e2 --device /dev/sdf








The EBS volume has been attached to our previously created EC2 Instance.


Hence, The Task is completed SuccessFully !!




Thank You for reading this article......πŸ™Œ






Keep Learning and Keep Sharing...

Thanks !! 

Connect me on Linkedin




Comments