Create an EBS Volume and Connect it to a EC2 Instance in AWS Using CLI | ARTH 2020

 


Task - 3


🔅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.



#aws #awscloud #awscsa #arthbylw #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #ARTH #linuxworld #makingindiafutureready #righeudcation



Step - 1 : Login to your AWS (Amazon Web Service ) Console.


Step - 2 : Then Click on Services which is on the left Upper Corner of the Console.



Step - 3 : Then find IAM Service and Click on IAM.


Step - 4 : Then Click on Users on the left Menu.


Step - 5 : Then Click on Add User Button.


Step - 6: Click on Next.



Step - 7 : Select Attach Existing Policies Directly.





Step - 8 : Then Download this file for Future use.




Step - 9 : Open Terminal if You are on Mac or Linux and open Command Prompt if you are on Windows.

And Type : aws  configure 





Step - 10 : Enter your AWS Access Key ID which you have created Now.


Step - 10 : Then enter your AWS Secret Access Key ID which you have created Now.



Step - 11 : Choose Your Region which will you found on the AWS console.




Step - 12 : Create a new Key Pair in CLI.

Command : aws ec2 create-key-pair --key-name Adarsh-CLI --query 'KeyMaterial' --output text > Adarsh-CLI.pem





Step - 13 : This command create a new key pair 
file with the provided name  into your current working directory.



Step - 14 : Now Again Click on services and go to EC2 Services.



Step - 15 : Then Click on Launch Instance.


Step - 16 : Then Copy the AMI of the instance which you want to launch through CLI.

And Click Select.


Step - 17 : Copy the type name you want to launch.

In my case I have chosen t2.micro.

Then Click on Next.



Step - 18 : Then Copy the subnet group id.

In my case it is :  subnet-34743579


Click on Next.




Click on Cancel.


Step - 19 : To launch the selected instance Using CLI, run the following Command.


aws ec2 run-instances  --image-id ami-0947d2ba12ee1ff75  --instance-type t2.micro  --count 1 --subnet-id subnet-34743579 --security-group-ids  sg-08d92e1128c4fff5e --key-name iAdarsh-CLI




You will find this type of screen will come.

Copy your instance id, we need it later.


(OPTIONAL )Step - 20 : Go to your AWS console you will a new instance is running with the same instance id which you have copied. this verifies that you are successfully launched a instance successfully.


Congratulations !!!!!




Step - 20 : Now to create a EBS Volume type the Following Command.

Command : aws ec2 create-volume \

    --volume-type gp2 \

    --size 1 \

    --availability-zone us-east-1d



Step - 21 : Copy the Volume-Id.



Step - 20 : Connect the Newly Created Volume to your instance .



Command : aws ec2 attach-volume --volume-id vol-05767a04700f1b9f4 --instance-id i-0449347ef5f79c22b --device /dev/sdf






















No comments:

Post a Comment

If you have any doubts, let me know.