AWS Command Line Interface

AWS Command Line Interface

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.

Description of Task:

  1. Create a new key pair.
  2. Create a Security group.
  3. Launch new EC2 instances using the created key-pair and security group.
  4. Create an EBS volume of 1GB.
  5. Attach the Storage/EBS volume to the launched instance.

SOLUTION:

STEP1:

Firstly we have to configure our AWS credentials by using the given command.

aws configure


No alt text provided for this image

STEP2:

now we create a keypair by using the given command.

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

STEP3:

now we create security group by using given command.

aws ec2 create-security-group --group-name myawssg --description  "Allow SSH"

To set ingress rule we use the given command.

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

STEP4:

we can also see the complete description about the security group by using given command.

aws ec2 describe-security-group --group-id sg-033ce882b7810cc26
No alt text provided for this image

STEP5:

now we launch the instance by using the given command.

aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --key-name mytaskkey --security-group-ids sg-033ce882b7810cc26 --count 1
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

STEP6:

Now we create the EBS Volume by using given command.

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

now we attach the volume that we created to the instance by using the given command.

aws ec2  attach-volume   --volume-id vol-0ec58f68411f43e16 --instance-id i-05c8b0cb7eda8db9e  --device /dev/sdh


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

STEP7:

In the last ,we detach the volume by using given command.

aws ec2  detach-volume  --volume-id vol-0ec58f68411f43e16
No alt text provided for this image

And then terminate the instance by using the given command.

aws ec2 terminate-instances --instance-ids i-05c8b0cb7eda8db9e
No alt text provided for this image

THANKYOU!!


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

Rittik Gupta的更多文章

社区洞察

其他会员也浏览了