AWS Command Line Interface(CLI)

AWS Command Line Interface(CLI)

Operations To be Performed are:

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

What is AWS CLI?

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

How to setup AWS CLI on your Laptop?

Step 1: Download and Install the AWS CLI using the following link:

https://awscli.amazonaws.com/AWSCLIV2.msi

Step 2: Go to Command line / Terminal and Run command "aws --version" to check whether the was is installed on your machine or not

No alt text provided for this image

Step 3: Now Login to your AWS Account using CLI

Note: To Login you should have access key and secret key. You can get these keys by adding new IAM user through IAM service of AWS.

  • To add IAM user:

a) Go to IAM Dashboard

No alt text provided for this image

b) Go to Users , then click add user:

No alt text provided for this image

c) Fill all the details and don't select "require password reset".

No alt text provided for this image

d) after filling details set permissions , add policy "PowerUserAccess" in "Attach existing policies directly"

No alt text provided for this image

e) It is optional to add tags

No alt text provided for this image

f) Now Review the details and click on "Create User"

No alt text provided for this image

g) Finally user is created and you can have "Access Key Id" and "Secret Access Key" for login using command line interface.

No alt text provided for this image

Command to login in your was account using AWS CLI is:

No alt text provided for this image

Step 4: Create Key Pair

aws ec2 create-key-pair --key-name <key name>
No alt text provided for this image

Check whether key pair is created or not using WebUI

No alt text provided for this image

Step 5: Create Security Group

aws ec2 create-security-group --group-name <SG group name> --description <description>
No alt text provided for this image

Check whether Security Group is created or not using WebUI

No alt text provided for this image

Step 6: Launch an Instance using the above created key pair and security group.

aws ec2 run-instances --image-id <image id> --instance-type <type of instance> --count <count of instance> --subnet-id <id of the subnet> --security-group-ids <security group ids> --key-name <name of the key>
No alt text provided for this image

Check whether Instance is created or not using WebUI

No alt text provided for this image

Step 7: Create an EBS volume of 1 GB

aws ec2 create-volume --volume-type <volume type> --size <size in gb> --availability-zone <zone name>
No alt text provided for this image

Check whether EBS Volume is created or not using WebUI

No alt text provided for this image

Step 8: Attach the above created EBS volume to the EC2 instance you created in the previous steps.

aws ec2 attach-volume --volume-id <id of the volume> --instance-id <instance id> --device <device name>
No alt text provided for this image

Check whether EBS Volume is attached to Instance or not using WebUI

No alt text provided for this image

Task Completed!!

Thankyou!!

To view or add a comment, sign in

More articles by Himangini Khanna

Others also viewed

Explore content categories