AWS CLI

AWS CLI

What is AWS CLI?

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

Why do we need AWS CLI?

AWS CLI gives you the ability to automate the entire process of controlling and managing AWS services through scripts. These scripts make it easy for users to fully automate cloud infrastructure. Prior to AWS CLI, users needed a dedicated CLI tool for just the EC2 service.

How to login through AWS CLI ?

To login through AWS CLI you need access key and secret key. We can get both of them by creating IAM user.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Further give username, give programmatic access and create custom password.

No alt text provided for this image

Select user policy as poweruseraccess.

No alt text provided for this image

Further give tags and click on create user. Then you will get access key and secret key.

No alt text provided for this image

Now go to command line and type following commands

aws configure, then further give access key , secret key , region name and output format.

No alt text provided for this image

Now we have logged in our aws account through cli.

Our task is:

1.Create a key pair

2.Create a security group

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

4. Create an EBS volume of 1 GB.

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

1.To create key pair command:

aws ec2 create-key-pair --key-name taskkeypair

We have created a key pair with name taskkeypair.

No alt text provided for this image

To check it is created or not you can verify it from webui.

No alt text provided for this image

2. Create a security group

To create a security a group using cli we use following command:

aws ec2 create-security-group --group-name tasksecuritygroup --description "for task"

No alt text provided for this image

To verify it we can check through webui.

No alt text provided for this image

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

To launch instance , select image ie type of os you want to launch redhat, windows etc, select number of os , select datacenter ie subnet id , select security group and key pairs.

command: aws ec2 run-instances --image-id ami-052c08d70def0ac62 --instances-type t2.micro --count 1 --subnet-id subnet-196a0155 --key-name taskkeypair --security-group-ids sg-0054aab75db9e099e

No alt text provided for this image

To verify again you can go to webui and verify.

No alt text provided for this image

4. Create an EBS volume of 1 GB.

To create volume you have to select volume type , specify size of storage and select datacenter.

command: aws ec2 create-volume --volume-type gp2 --size 1 --availability-zone ap-south-1b

No alt text provided for this image

Go to webui and check volume id to verify.

No alt text provided for this image

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

To attach EBS volume to instance through cli you need to give volume id ,instance id and device name.

command: aws ec2 attach-volume --volume-id vol-0b2233821085ce424 --instance-id i-06217cc805d3693e3 --device /dev/sdf

No alt text provided for this image

To verify go to webui .

No alt text provided for this image

Thank You!!!

To view or add a comment, sign in

More articles by Sairaj Sarde

  • JENKINS

    What is Jenkins? Jenkins is a free and open source automation server. It helps automate the parts of software…

  • Configuring Httpd Server On Docker Container

    TASK Configure httpd server on docker container Creating container Command: docker run -it --name conatiner_name…

  • Azure Kubernetes Service (AKS)

    What is Microsoft Azure? Azure is a public cloud computing platform—with solutions including Infrastructure as a…

  • Networking

    Create a Setup so that you can ping google but not able to ping Facebook from same system Here you can see my IP…

  • What is Kubernetes, its need and case studies

    What is Kubernetes? Kubernetes (also known as k8s or "kube") is an open source container orchestration platform that…

  • Benefits of using Ansible.

    What is Ansible ? Ansible is an open-source software provisioning, configuration management, and application-deployment…

  • CONFIGURING WEBSERVER THROUGH AWS CLI

    TASKS TO BE PERFORMED Webserver configured on EC2 Instance - Document Root(/var/www/html) made persistent by mounting…

  • Benefits of ML

    Have you ever heard the term AI/ML?? These are the most trending words now a days. Everyone is talking about these…

  • BIGDATA

    What is Big Data? Big data usually includes data sets with sizes beyond the ability of commonly used software tools to…

  • Case study of Netflix using AWS cloud platform

    Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 175 fully…

Others also viewed

Explore content categories