AWS Command Line Interface

kore arvind
5 min readOct 17, 2020

šŸ¤©Letā€™s see some intersting thing about AWS CLI.

To work or use AWS Cloud we can use two methods:

  • WebUI.
  • AWS CLI(Command Line Interface).

The WebUI we use normally to work with AWS Cloud. but, Today letā€™s see how we can work with AWS CLI.

What is AWS CLI ā“

AWS Command Line Interface (CLI) is a unified tool to manage AWS services using Command Line Interface.

Before that we have to setup the AWS CLI

šŸ’Ø SETUP interface by installing the CLI SDK tool.

SDK CLI tool

After installing the SDK tool we have to configure the AWS CLI to manage services but, before this we need to create the IAM user with Administrator access. Which gives the Access Key and Access Secret Key to login in AWS in command line.

if you have IAM user you can login through it ,if donā€™t have IAM user first login to AWS .

goto IAM user Dashboard and click on the users.

šŸ‘‰if you have the user you can use. but, if donā€™t have you can create by clicking Add user.

šŸ‘‰after clicking the Add user you get the interface of creating IAM user.

šŸ‘‰for new user, User name and for working with AWS using cli we have to select the option AWS Management Console access and next:permissions.

In set permissions ,select Attach exixting policies directly and select PowerUserAcces then click next, if want to add tag then add tag otherwise click next .

After successfully creating the IAM user Access Key Id and Secret access Key generated. by using them we can Configure.

šŸ‘‰Now let us configure AWS usingCLI .

now letā€™s ask for some help of AWS to know what we can do..

a command used for configuration

aws configure

here we user the Access key ID ,Secret access key and Region to login to IAM user which generated when you created.

Up to now we have setup the SDK tool and we have configured the AWS.

Now letā€™s see the some intersting commands which perform different tasks.

šŸ˜²letā€™s see some basics command today.

šŸ‘‰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 and attach to the instance we created above and detach the volume.

Create a key pair :

A Key pair is a private key which is used to connect to the EC2 instance . when you lunch any instance we use this private key as password for login.

aws ec2 create-key-pair - -key-name <keyname> - -query keyMaterial - -output text > <keyname>.pem

it will create and Download the key pair with .pem and downloaded in .pem format.

the key pair is created, we can use this key pair when we are lunching the instance.

Create a security group:

command to create security group

aws ec2 create-security-group - -group-name <name> - -description <description>

and letā€™s look does security group is created properly or not.

using above command we only create the Security Group but we canā€™t create inbound rule.To set inbound rule to authorize the traffic the command is

aws ec2 authorize-security-group-ingress - -group-id <group id> - -group-name <groupname> - -protocol <protocolname> - -port <portnumber> - -cidr <cidrblocknumber>

The inbound rule created.

Launch an instance using the above created key pair and security group :

To launch the EC2 instance we are using the key pair and security that we created. the command to launch the EC2 instance is

aws ec2 run-instances - -image-id <imageid> - -instance-type- -<instancetype>count <count> - -subnet-id <subnetid> - -security-group-ids <securitygroupid>n- -key-name <keyname>

and letā€™s look does instanc is created properly or not.

Creating an EBS volume of 1 GB and attach to the Ec2 instance that we created:

To create the EBS volume command is

aws ec2 create-volume - -availability-zone <zone name> - -size <size>

and letā€™s look does EBS volume is created properly or not.

To attach the EBS volume to the EC2 instance the command is

aws ec2 attach-volume - -volume-id <volumeid> - -instance-id <instanceid> - -device <devicename>

volume is attached to the EC2 instance.

detach the EBS from the EC2 instance

The command to detach is

aws ec2 detach-volume - -volume-id <volumeid> - -instance-id <instanceid>

EBS is detached from the EC2 instance.

Today we have learned some intersting things about AWS CLI and how to use them .

futher we look with more commandsā€¦..

Thank you for reading ā€¦..šŸ˜Š

--

--