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