AWS console managing via AWS CLI

AWS console managing via AWS CLI

Welcome you guys in my article based on AWS CLI.

Task Description:

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

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

Process of completion:

  1. Install AWS CLI:

I have installed AWS CLI. To check whether it is installed or not use the following command:

aws --version
No alt text provided for this image

Here, I have successfully installed AWS CLI. Now we can use it to do the things automatically in AWS management console.

2. Configure AWS profile:

To configure the AWS profile for the first time we have to use following command-

aws configure [--profile profile-name] 

Here, I have used already configured profile.

No alt text provided for this image

3. Create a key pair:

aws ec2 create-key-pair --key-name awscsatask
No alt text provided for this image

Description of key pair:

No alt text provided for this image

Now, we can see our key pair is created.

No alt text provided for this image

4. Create a security group:

aws ec2 create-security-group --description "sg_aws_task" --group-name awstasksg --vpc-id vpc-03ad93c5504a4e790
No alt text provided for this image

Description of Security Group:

No alt text provided for this image

Here, desired security group is created.

No alt text provided for this image

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

aws ec2 run-instances --image-id ami03ab428f950fdc05a --security-group-ids sg-0fd8169e1f76f18d9 --instance-type t2.micro --count 1 --key-name awscsatask
No alt text provided for this image

Description of ec2 instance:

No alt text provided for this image

Instance is successfully created.

No alt text provided for this image

6. Create an EBS volume of 1 GB:

aws ec2 create-volume --availability-zone ap-south-1a --volume-type gp2 --size 1
No alt text provided for this image

You can see here volume is created with desired size.

No alt text provided for this image

7. Attach the above created EBS volume to the instance created in the previous step:

aws ec2 attach-volume --volume-id vol-04b297fe77490f54bd --instance-id i-033246ae49595f43c --device /dev/xvdh
No alt text provided for this image

Here, our created EBS volume is successfully attached to the instance.

No alt text provided for this image

Now, we can detach this volume by using-

aws ec2 detach-volume volume-id vol-04b297fe77490f54bd

To stop or terminate the launched instance we have commands-

aws ec2 stop-instance --instance-ids i-033246ae49595f43c

aws ec2 terminate-instance --instance-ids i-033246ae49595f43c

And here I am done with my task.

Thank you all for your time!!!

Anushka Visapure

Solution-Oriented DevOps Engineer || Skilled in Kubernetes | Terraform | Ansible | Docker | Git and GitHub | GitHub Action || Expanding Capabilities in AWS | GCP | Linux.

4y

Great Nivedita Shinde ✨✨

Onkar Naik

DevOps @Forescout 🔐 | Google Developer Expert | AWS | DevOps | 3X GCP | 1X Azure | 1X Terraform | Ansible | Kubernetes | SRE | Platform | Jenkins | Tech Blogger 🚀

4y
Aditya Sharma

Student @ Lost Stories Academy | Music

4y

Congrats...

Nilesh Gopale

MTS 2 @Cohesity | Ex-Veritas | Kubernetes | Docker | Golang | Python

4y

Great work ✨

To view or add a comment, sign in

More articles by Nivedita Shinde

Insights from the community

Others also viewed

Explore topics