AWS CLI Usage

CLI or Command Line Interface provides a lot of power to the AWS that we cannot do in the Web UI provided by the AWS.

In this task we have to:

  1. Create a key pair
  2. Create a security group
  3. Launch an instance using the above created key pair and security group.
  4. Create an EBS volume of 1 GB.
  5. The final step is to attach the above created EBS volume to the instance you created in the previous steps.

AWS CLI Configure

aws configure

Creating Key Pair

aws ec2 create-key-pair --key-name <key-name>

Creating a Security Group

aws ec2 create-security-group --group-name <group-name>--description "<Description>" --vpc-id <vpc-id>

Launching Instance

aws ec2 run-instances --image-id <image-id> --instance-type <instance-type> --count <number-of-instances> --subnet-id <subnet-id> --security-group-ids <sg-id> --key-name <key-name>

Creating EBS Volume

Create EBS Volume and EC2 Instance in the same Availability Zone.

aws ec2 create-volume --availability-zone <availability-zone> --size <size> --volume-type <type>

Attaching the EBS Volume to the running instance

aws ec2 attach-volume --volume-id <volume-id>  --instance-id <instance-id> --device <device-name>

We can see that there are now two volumes attached to our instance.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store