Accessing AWS from CLI

Accessing AWS from CLI

Task 3 at Arth for accesing AWS from CLI

Task Description:

  1. Create a key pair
  2. Create a security group
  3. Launch an instance using the created key pair and security group
  4. Create an EBS volume of 1GB
  5. Attach the created EBS volume with the instance created prevoiusly.

To solve the above problem we must firstly install AWSCLI from the internet over our machine.

Then we have to run the command

aws configure

This command is used to set the user and password using the AWS Access Key ID and AWS Secret Access Key provided at the time of creating the IAM user

We can get help for any command using

  aws help
  aws <command> help
  aws <command> <subcommand> help
 
  1. To create a key pair we use the command
aws ec2 create-key-pair --key-name awscli-key 
No alt text provided for this image

2. Creating a security group

aws ec2 create-security-group --group-name AWSCLI --description "Security group created by CLI" 
No alt text provided for this image

3. Launching the instance using the key pair and security group created

aws ec2 run-instances --image-id ami-0a54aef4ef3b5f881 --count 1 --instance-type t2.micro --key-name awscli-key --security-groups AWSCLI
No alt text provided for this image

4. Create an EBS volume of 1 GB

aws ec2 create-volume --availability-zone us-east-2c --size 1 --volume-type gp2  
No alt text provided for this image

5. Connect the EBS to ithe instance created earlier.

aws ec2 attach-volume --volume-id vol-0883a84c4a3a65960 --instance-id i-02ae91e27033e7686 --device /dev/sdf 
No alt text provided for this image

Now that all the all the steps have been done we can cross-check it from the WebUI

  1. Created Security Group
No alt text provided for this image

2. Instance created

No alt text provided for this image

3. EBS volume that was created and connected to the instance

No alt text provided for this image

From following these steps we can launch a instance from newly created security groups and key pair that attach an external storage with it using the Command Line Interface.

To view or add a comment, sign in

More articles by Devansh Sharma

Insights from the community

Others also viewed

Explore topics