LAUNCHING AWS INSTANCE AND ATTACHING EBS VOLUME USING AWSCLI
Manmohan .
Sr.Executive DevOps Engineer | Ex-DevOps Engineer at Mediamelon.Inc | DevOps | AWS | Big Data | Hadoop | Kubernetes | Jenkins | Docker | AKS | EKS | Azure DevOps | CI-CD | RHCSA8 | RH294 | GitOps | DevSecOpsk
for performing this activity requires AWSCLI and some services of AWS like EC2 and EBS.
EC2 SERVICE :-
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Amazon EC2's simple web service interface allows you to obtain and configure capacity with minimal friction.
EBS SERVICE :-
Amazon Elastic Block Store (EBS) is an easy to use, high performance block storage service designed for use with Amazon Elastic Compute Cloud (EC2) for both throughput and transaction intensive workloads at any scale. A broad range of workloads, such as relational and non-relational databases, enterprise applications, containerized applications, big data analytics engines, file systems, and media workflows are widely deployed on Amazon EBS.
About the 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.
? All the above steps must be performed using AWS CLI.
Let's start the steps required to complete the task
First, download AWS CLI software and after downloading check the software is successfully installed in system or not.
use command :- aws --version
set the access key and secret key by using “aws configure” command.
for this secret key and access key first create IAM user from there download the keys. This keys will help in accessing the AWS console its like username and password.
next step is to create key pair which will help in access the instances launched.
command:-
aws ec2 create-key-pair --key-name
Key pair has been successfully created. You can confirm with AWS portal also.
now create security group which will allow traffic/services coming in or going out.
command :-
aws ec2 create-security-group --description { } --group-name { }
Security group has been created. check it from AWS portal.
launch an instance using above created Key pair and Security group.
command :-
aws ec2 run-instances --image-id { } --instance-type { } --count {} --subnet-id { } --security-group-id { } --key-name {}
Let’s go to the AWS portal and see whether the instance has been launched or not.
Instance has been launched successfully.
Now it’s time to create a EBS volume depending upon requirement.
command :-
aws ec2 create-volume --availability-zone {} --size {} --volume-type gp2
check whether volume is created or not.
now attach the created volume to the instances launched.
command :-
aws attach-volume --device /dev/xvdh --instance-id {} --volume-id {}
go to the AWS console whether the volume is connected or not.
Volume has been attached successfully. Let’s confirm from the instance page also.
Hence we have launched the instance and attached the volume created, hence the final goal of task has been acheived.