To perform actions of AWS Cloud using AWS CLI Interface…

Poojya Puju
4 min readOct 16, 2020

In AWS Cloud to perform actions we can use two methods:

  • WebUI.
  • AWS CLI.

We all know how WebUI works. let us see how to perform actions in AWS using CLI.

🤔What is AWS CLI ❔

AWS Command Line Interface (CLI) is a tool that is used to manage the WS services through the Command line.

👉Firstly to use AWS CLI we need to install the CLI SDK tool.

After installing it we need to configure the AWS CLI to manage services but before that, we need to create the IAM user with Administrator access. Which gives the Access Key and Secret Key to login in CLI.

Now let us configure AWS CLI by using the command.

aws configure

Here we use the Access key and Secret key to log in to AWS CLI.

Let us perform some actions like:

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

Creating Key Pair:

The key pair is the private key which we use to connect to the EC2 instance. For creating Key pair the command is

aws ec2 create-key-pair — key-name <keyname>

To download the key in the .pem file we need command is

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

The key pair is generated and downloaded in a given location.

Creating a Security Group:

Command to create a security group is

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

Security group created.

By the command, we can create a security group but we can’t create inbound or ingress 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 is created.

Launch one EC2 instance using the above 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> — key-name <keyname>

The instance created with the above key pair and security group.

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>

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.

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

That’s all…

Thanks For Reading…🤝

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response