Launching Instance & Attaching EBS Volume using AWS CLI - AWS CSA & Developer Training

Launching Instance & Attaching EBS Volume using AWS CLI - AWS CSA & Developer Training

In this Task, we will be launching an EC2 Instance, and EBS Volume. Then we will connect this volume to our Instance using AWS CLI.

This task is part of my AWS CSA & Developer Training.

WHAT is AWS?

Amazon web service is a platform that offers flexible, reliable, scalable, easy-to-use and cost-effective cloud computing solutions. AWS is a comprehensive, easy to use computing platform offered Amazon. The platform is developed with a combination of infrastructure as a service (IaaS), platform as a service (PaaS) and packaged software as a service (SaaS) offerings.

WHAT is AWS CLI?

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

About 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 and attach to the instance we created above

** All the above steps must be performed using AWS CLI

Let's Start:

# First create an IAM user, here I have already provided AdministratorAccess to the user vimal.

Step 1: To check whether the AWS CLI program installed properly or not, use this cmd.

# aws --version
No alt text provided for this image

Step 2: Lets Authenticate to our AWS account using the IAM user we created, provide Access key, secret key & Region, using this cmd

  # aws configure
No alt text provided for this image

Step 3: Creating a key pair: using this key pair only we can access our instance which we are going to launch further

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

Step 4: Creating Security Group

# aws ec2 create-security-group --description "SSH protocol allowed" --group-name myawssg
No alt text provided for this image
No alt text provided for this image

Step 5: Allowing SSH through firewall

# aws   ec2   authorize-security-group-ingress  --group-id  sg-0795062e6736a0a64    --protocol tcp --port 22 --cidr 0.0.0.0/0
No alt text provided for this image
No alt text provided for this image

Step 6: Verifying Security group from CLI

# aws ec2 describe-security-groups --group-id sg-0795062e6736a0a64
No alt text provided for this image
No alt text provided for this image

Step 7: Launching EC2 Instance

# aws ec2 run-instances --security-group-ids sg-0795062e6736a0a647 --instance-type t2.micro  --count 1  --image-id  ami-052c08d70def0ac62  --key-name myawskey1
No alt text provided for this image
No alt text provided for this image

Step 8: Creating an EBS Volume:

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

Step 9: Attaching EBS Volume to the Instance

# aws  ec2   attach-volume   --instance-id   i-000645a164e42f20c   --volume-id  vol-0f235bd8d5a1059e1   --device   /dev/sdh
No alt text provided for this image
No alt text provided for this image

Step 10: Verifying EBS attachment

No alt text provided for this image

Task Completed

Thanks


To view or add a comment, sign in

Others also viewed

Explore content categories