The CLI approach to AWS Cloud

Divyanshu Sharma
7 min readNov 19, 2020

What is the CLI approach ????

CLI is known as Command Prompt. Unlike the Graphical screen where you manually work, CLI brings ease as you just need to type in the command….

The use of CLI in AWS not only helps us with numerous facilities and is also user flexible. It can be manipulated according to the user's needs.

How to use this approach ????????

To use the command line in accessing the services of AWS. The minimum requirements are

1. Download AWS CLI Command software from the browser.

2. Create an IAM user in the AWS console.

Creating an IAM user :

  1. Go to AWS management console

2. Go to services. Choose IAM service under Security.

3. Create a new user in the IAM services.

Choose the programmatic access option

3. This option provides you with an access key and a secret key. These credentials are confidential. They help you to configure AWS in the command line.

4. Add permission to the IAM user.

5. Proceed further step by step and your user is created. This provides you an access key and secret key.

Configuring AWS ACCOUNT

The next step is to configure aws account using these keys. Go to cmd and type aws configure .

Add the credentials and keep them confidential.

CREATE KEY PAIR

For creating pairs lookout for the desired commands using the help keyword.

The command aws ec2 help gives all the options under it.

##Key Pair: A key pair, consisting of a private key and a public key, is a set of security credentials that you use to prove your identity when connecting to an instance. Amazon EC2 stores the public key, and you store the private key. You use the private key, instead of a password, to securely access your instances.

##Synopsis:-

create-key-pair
— key-name <value>
[ — dry-run | — no-dry-run]
[ — tag-specifications <value>]
[ — cli-input-json | — cli-input-yaml]
[ — generate-cli-skeleton <value>]
[ — cli-auto-prompt <value>]

##Command use: aws ec2 create-key-pair — key-name AWSKEY1.

The key pair returned to you is available only in the Region in which
you create it. If you prefer, you can create your own key pair using a
third-party tool and upload it to any Region using ImportKeyPair. You can save the key in the yellow box by adding .pem extension for later use.

Creating a Security Group :

A security group acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. Inbound rules control the incoming traffic to your instance, and outbound rules control the outgoing traffic from your instance. … If you don’t specify a security group, Amazon EC2 uses the default security group.

You can create security groups to use in a virtual private cloud (VPC), or in the EC2-Classic shared flat network. You can assign a user friendly name for the same.

Use the AWS Command Line Interface (AWS CLI) to create a security group, add rules to existing security groups, and delete security groups.

## Synopsis :

create-security-group
— description <value>
— group-name <value>
[ — vpc-id <value>]
[ — tag-specifications <value>]
[ — dry-run | — no-dry-run]
[ — cli-input-json | — cli-input-yaml]
[ — generate-cli-skeleton <value>]
[ — cli-auto-prompt <value>]

##Command :

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

Launch Instance :

Instances in AWS are basically virtual environments. These virtual environments are isolated from the underlying base OS. It’s an On-demand service, i.e. a user can rent the virtual server(instances) on an hourly basis and deploy their applications on it.

When you launch your instance, you can launch your instance in a subnet that is associated with one of the following resources:

  • An Availability Zone — This option is the default.
  • A Local Zone — To launch an instance in a Local Zone, you must opt in to the Local Zone, and then create a subnet in the zone. For more information, see Local Zones
  • A Wavelength Zone — To launch an instance in a Wavelength Zone, you must opt into the Wavelength Zone, and then create a subnet in the zone. For information about how to launch an instance in a Wavelength Zone, see Get started with AWS Wavelength in the AWS Wavelength Developer Guide.
  • An Outpost — To launch an instance in an Outpost, you must create an Outpost. For information about how to create an Outpost, see Get Started with AWS Outposts in the AWS Outposts User Guide.

After you launch your instance, you can connect to it and use it. To begin, the instance state is pending. When the instance state is, the instance has started booting. There might be a short time before you can connect to the instance.

##Synopsis :

run-instances
[ — block-device-mappings <value>]
[ — image-id <value>]
[ — instance-type <value>]
[ — ipv6-address-count <value>]
[ — ipv6-addresses <value>]
[ — kernel-id <value>]
[ — key-name <value>]
[ — monitoring <value>]
[ — placement <value>]
[ — ramdisk-id <value>]
[ — security-group-ids <value>]
[ — security-groups <value>]
[ — subnet-id <value>]
[ — user-data <value>]
[ — additional-info <value>]
[ — client-token <value>]
[ — disable-api-termination | — enable-api-termination]
[ — dry-run | — no-dry-run]
[ — ebs-optimized | — no-ebs-optimized]
[ — iam-instance-profile <value>]
[ — instance-initiated-shutdown-behavior <value>]
[ — network-interfaces <value>]
[ — private-ip-address <value>]
[ — elastic-gpu-specification <value>]
[ — elastic-inference-accelerators <value>]
[ — tag-specifications <value>]
[ — launch-template <value>]

##Command :

$ aws ec2 run-instances — image-id ami-0e306788ff2473ccb — instance-type t2.micro — count 1 — subnet-id subnet-76a4dd3a — key-name AWSKEY1— security-group-ids sg-08e69bf382cf62d81"

Creating EBS Storage :

What is EBS ??????

Amazon Elastic Block Store (EBS) is a block storage system used to store persistent data. Amazon EBS is suitable for EC2 instances by providing highly available block-level storage volumes. It has three types of volume, i.e. General Purpose (SSD), Provisioned IOPS (SSD), and Magnetic.

A block storage volume works similarly to a hard drive. You can store any type of files on it or even install a whole Operating System on it. EBS volumes are placed in an availability zone, where they are automatically replicated to protect data loss from the failure of a single component.

Creation of EBS :

Use the command under the create volume option.

##Synopsis

create-volume
— availability-zone <value>
[ — encrypted | — no-encrypted]
[ — iops <value>]
[ — kms-key-id <value>]
[ — outpost-arn <value>]
[ — size <value>]
[ — snapshot-id <value>]
[ — volume-type <value>]
[ — dry-run | — no-dry-run]
[ — tag-specifications <value>]
[ — multi-attach-enabled | — no-multi-attach-enabled]
[ — cli-input-json | — cli-input-yaml]
[ — generate-cli-skeleton <value>]
[ — cli-auto-prompt <value>]

##Command Use :

aws ec2 create-volume — availability-zone ap-south-1a — no-encrypted — size 1

##Attaching EBS :

Attaches an EBS volume to a running or stopped instance and exposes it
to the instance with the specified device name.After you attach an EBS volume, you must make it available. For more
information, see Making an EBS Volume Available For Use.

Synopsis:-

attach-volume
— device <value>
— instance-id <value>
— volume-id <value>
[ — dry-run | — no-dry-run]
[ — cli-input-json | — cli-input-yaml]
[ — generate-cli-skeleton <value>]
[ — cli-auto-prompt <value>]

Command:-

aws ec2 attach-volume — instance-id i-09bc13e9703767815— volume-id vol-0404cfce970a0b167— device xvdh

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

Thankyouuuuuu…………….

--

--