Launching New Instance Using AWS CLI !!!!

Launching New Instance Using 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. 

Amazon Web Services:

Amazon Web Services (AWS) is a subsidiary of Amazon providing on-demand cloud computing platforms and APIs to individuals, companies, and governments, on a metered pay-as-you-go basis. These cloud computing web services provide a variety of basic abstract technical infrastructure and distributed computing building blocks and tools. One of these services is Amazon Elastic Compute Cloud (EC2), which allows users to have at their disposal a virtual cluster of computers, available all the time, through the Internet.

STEPS :

  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 the AWS management console.

2. Configure AWS profile:

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

aws configure [--profile profile-name]

No alt text provided for this image

3. Create a key pair :

aws ec2 create-key-pair --key-name aws_task_1

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_1" --group-name awstask1 --vpc-ids vpc-053bdb6e

No alt text provided for this image

Description of Security Group:

No alt text provided for this image

Here, the 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 "image_id "--security-group-ids "security_group_id" --instance-type "t2.micro" --count 1 --key-name "key_name"

No alt text provided for this image

Description of ec2 instance:

No alt text provided for this image

The instance is successfully created.

No alt text provided for this image
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 the 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 "volume_id" --instance-id "instance_id " --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 "volume_id"

No alt text provided for this image

To stop or terminate the launched instance we have commands-

aws ec2 stop-instance --instance-ids "instance_id"

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

aws ec2 terminate-instance --instance-ids "instance_id"

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

And here I am done with my task.

Thanks for reading !!!!!!


Mahesh Thorat

Software Developer @FYNDNA

4 年

Great ??

Udit Sharma

DevOps Engineer @Drona Pay | Redhat Certified | Freelancer Skilled at AWS | GCP | Azure | Terraform | Kubernetes | Ansible | Git ,GitHub | Linux | Openshift | Big Data | ML | DL | Python | C++

4 年

Gr8 Job

Great Work

Mohit Jangir

Sr. Cloud Engineer @Searce | DevOps & Kubernetes Enthusiast | Building Resilient Cloud-Native Applications

4 年

Great work, anushka? Well done

要查看或添加评论,请登录

Anushka Visapure的更多文章

社区洞察

其他会员也浏览了