AWS Command through CLI

Vijayamurugan LND
3 min readDec 5, 2020

Summary:

Step 1: Create a key pair

Step 2 : Create a Security Group

Step 3 : Launch an Instance using the above created Key Pair and Security Group

Step 4 : Create an EBS volume of 1GB

Step 5 : Attach the EBS volume to the instance

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?

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

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

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

Login to your AWS Account using CLI

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.

  • Go to IAM Dashboard
  • Go to Users ->add user
  • Fill all the details & don’t select “require password reset”
  • Set permissions , add policy “PowerUserAccess” in Attach existing policies directly
  • It is optional to add tags, then review the details and click on “Create User”
  • Finally user is created and you can have “Access Key Id” and “Secret Access Key” for login using command line interface.
  • IAM user is created

Configuring the AWS user in CLI

command: aws configure

1.Create a key pair:

command: aws ec2 create-key-pair — key-name cli-key

2.Create a Security Group:

command: aws ec2 create-security-group — description “security group creation using cli” — group-name cli-sec-grp

To add rule

command: aws ec2 authorize-security-group-ingress — group-name cli-sec-grp — protocol tcp — port 22 — cidr 0.0.0.0/0

To see details of Security Groups:

command: aws ec2 describe-security-groups

3.Launch an Instance using the above created Key Pair and Security Group:

command: aws ec2 run-instances — image-id <image id> — instance-type <instance type> — key-name <key name> — security-group-ids <security id> — subnet-id <subnet id> — count 1

4.Creating EBS volume:

command: aws ec2 create-volume — availability-zone ap-south-1a — size 1

5.Attach the EBS volume to the instance

command: aws ec2 attach-volume — device xvdh — instance-id i-0a21b80a618bcf43f — volume-id vol-055a6d4f8c0fab6ba

Thank you:-)

#awscloud #awscli #aws #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeudcation #arthbylw #awsbylw

--

--