Abhishekkumawat
3 min readOct 17, 2020

What is the AWS CLI?

AWS CLI is a unified tool for running and managing your various AWS services. Just download and install the tool and you will be able to control multiple AWS services from the command line. Obviously, this can also be done from the AWS management console, but for developers who like the command line in either Linux or Windows this is a great tool for managing your AWS services.

Creating a simple AWS AMI

In this section, I am going to discuss how to carry out a simple task like creating a simple AWS AMI with the previously installed command line tools. The first thing required is that you configure your machine for use with AWS CLI. To do this we must first get the security credentials for our AWS account. Log in to your AWS account and click on the drop-down menu at the top right of the screen usually where your name is and select security credentials and then access keys to get your credentials. Once you have them copy them into a text file and open the command line and type the command AWS configure. When you run this command it will prompt you to add your credentials and once you have done this you should have access to your AWS services.

1. Creating a Security Group

The first thing I am going to do is create a security group and I order to do this we just need to run a simple command to do so.

Once this command has finishes you can go to your AWS management console to view the security group you created.

2. Create a Key Pair

create your key pair. The commands to do this is as follows:

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

In order to run an ec2 instance there are a few things we must get from the management console like the image id and the image type. Once you have retrieved these we are ready to start creating our instance.

Run the following command:

The count is just telling AWS how many instances you wish to create.

You can now go to the management console to check that your instance was created. Once your instance is up and running, you can access it via putty using your .ppk file created earlier.

4. Create an EBS volume of 1 GB

Attaches an EBS volume to a running or stopped instance and exposes it to the instance with the specified device name.

Encrypted EBS volumes must be attached to instances that support Amazon EBS encryption. For more information, see Amazon EBS Encryption in the Amazon Elastic Compute Cloud User Guide .

5. The final step is to attach the above created EBS volume to the instance you created in the previous steps.

run the following command:

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>]