πŸ”Ί Automating AWS through CLI πŸ”»

Dileepkumar
3 min readMar 18, 2021

In this article we will be Automating AWS using AWS CLI

πŸ”Ά Step 1: Create a key pair
πŸ”Ά Step 2: Create a security group
πŸ”Ά Step 3: Launch an instance using the above created key pair and security group.
πŸ”Ά Step 4: Create an EBS volume of 3Gib.
πŸ”Ά Step 5: The final step is to attach the above created EBS volume to the instance you created in the previous steps.

So lets start

Firstly lets create a IAM user on AWS so that we can login through our local system Command prompt

Select Programmatic Access so that we can login through CLI
Give Power user
Remember the access key and Secret key

Now to login through Windows Command prompt run the following command

aws configure

Now we have finally login to AWS account through cmd prompt

Step 1: Create a key pair πŸ”»

Firstly lets create Key pair

Here no need to remember all the commands we can use β€œhelp” cmd to get help

scroll down will get required cmds
aws ec2 create-key-pair β€” key-name Task3-key-pair

Key pair Created

Step 2: Create a security group πŸ”»

aws ec2 create-security-group β€” group-name mytask3SG β€” description β€œMy task 3 SG β€œ

Finally Security group Created

Step 3: Now lets Launch an instance using the above created key pair and security group. πŸ”»

aws ec2 run-instances β€” image-id ami-081bb417559035fe8 β€” instance-type t2.micro β€” subnet-id subnet-e5676e8d β€” count 1 β€” security-group-ids sg-0510ab305b73bbbe6 β€” key-name Task3-key-pair

Successfully Instance Created

Step 4: Create an EBS volume of 1 GB. πŸ”»

aws ec2 help
aws ec2 create-volume β€” volume-type gp2 β€” size 3 β€” availability-zone ap-south-1a

Successfully Created volume of 3 Gib

Step 5: The final step is to attach the above created EBS volume to the instance you created in the previous steps. πŸ”»

aws ec2 attach-volume β€” volume-id vol-0ee96decd8a9bf8a1 β€” instance-id i-07a6f66189e45c729 β€” device /dev/sdf

Finally EBS volume has been attached to the above created ec2 instance using CLI.

Hope it helped you ..!

Thanks for Reading 😁✌

--

--