AWS CLI version2 — Hands-On

Giuamendolara
4 min readOct 18, 2020

Is there a different way to provision the resources in the AWS infrastructure? Yes, and in this article, I will provide a breakdown of how to use the AWS CLI version 2 tool.

We are all used to the GUI; It is a very intuitive tool for interacting with the AWS’ resources but it doesn’t provide granularity (Imagine to spin up multiple EC2 instances at the same time, but with different characteristics).

TASK OUTLINE:

1. Create a Key pair

2. Create a Security Group

3. Spin up an EC2 instance, harnessing the key pair and the security group aforementioned

4. Create an EBS volume of 1GB

5. Attach the volume to the EC2 instance

First, we have to download and install the AW CLI (Command Line Interface) version 2 tool. However, I will also show an alternative method, in case you do not want to use your machine for managing your AWS services:

WALKTHROUGH:

1. Download and install AWS CLI version2 (in this example I will use Windows 10 as OS)

2. Verify that the software has been installed correctly

3. Create an ad-hoc user on IAM

4. Attach a managed policy that can permit the full control

5. Save the programmatic credentials: access key and secret access key

6. Launch AWS configure and insert the parameters

7. Create the Key Pair [aws ec2 create-key-pair –key-name awstask3]

8. Verify on the GUI

9. Create the Security Group

[aws ec2 create-security-group –vpc-id vpc-0987f138ccb7d3d7c –description “TASK#3” -group-name AWSTASK3]

10. Verify on the GUI

11. Spin up the EC2 instance

[aws ec2 run-instances — image-id ami-00a205cb8e06c3c4e

— instance-type t2.micro — count 1 — security-group-ids sg-0ceacc03c3d40270f — key-name AWSTASK3 — subnet-id subnet-03e24c08d5b2ff4bd]

12. Verify on the GUI

13. Now it’s time to create an extra EBS data volume

[aws ec2 create-volume — availability-zone eu-central-1c — size 1]

14. Verify on the GUI

15. Attach the volume on the EC2 instance created before

[aws ec2 attach-volume — instance-id i-097470ad9f4b2f191 — volume-id vol-0f0754d4141a9b48a — device /dev/sdh]

16. Verify on the GUI

The purpose of this activity is to demonstrate how powerful the cli is.

I want to thank the mentor: Sir VIMAL DAGA.

THANK YOU PEOPLE

--

--