Launching EC2 Instance using CLI and attaching an EBS volume

Launching EC2 Instance using CLI and attaching an EBS volume

 What is the Amazon web service?

Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 175 fully-featured services from data centers globally. Millions of customers including the fastest-growing startups, largest enterprises, and leading government agencies are using AWS to lower costs, become more agile, and innovate faster. More than 90%of the world’s biggest public game companies, including Activision, Supercell, and Ubisoft, are using AWS.

What are the Command-line interface (CLI) and AWS (CLI)?

A command-line interface process commands to a computer program in the form of lines of text. The program which handles the interface is called a command-line interpreter or command-line processor. Similarly, 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 use 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.

In this task

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

Prerequisites for this task

  1. Installed AWS version 2 on your os. If not use this link to download https://awscli.amazonaws.com/AWSCLIV2.msi
  2. An AWS account.

Let's configure the CLI of AWS

  • Check if the AWS CLI is installed or not by running this command

C:\> aws --version

aws-cli/2.0.47 Python/3.7.4 Windows/10 botocore/2.0.0

#To create an access key for an IAM user

1. Sign in to the AWS Management Console and open the IAM console

2. Search for users and create one

No alt text provided for this image

#We need to give permissions to a user to successfully authenticate with CLI.

No alt text provided for this image

#After this step create a user and the Access Key and Secret key will be displayed

No alt text provided for this image

#We have successfully created a user

#To configure AWS we need the following things:

Access key ID Secret access key AWS Region Output format

No alt text provided for this image

#To connect with the Ec2 instance we need a private key, If you already have the key no need to create

No alt text provided for this image

#We can create a new security group.

No alt text provided for this image

#After getting all things ready Let's launch an ec-2 instance.

No alt text provided for this image

#We can cross-check it by using the GUI or CLI.

No alt text provided for this image

#In this image, the instance is starting, and After the instance is started we are gonna create an EBS volume of 1 GB.

#The command for Creating EBS volume is

NOTE: To successfully attach a volume to an instance both instances and volume should be in the same region.

Let's view in GUI if the volume is created or not

No alt text provided for this image

#Now we have to connect the EBS volume of 1 GB to the EC-2 instance we created.

No alt text provided for this image

 successfully we done!!

Thanks for reading 🙋♂️







To view or add a comment, sign in

More articles by Faizan Shaikh

Explore content categories