AWS CLI Infrastructure and Using CMD to launch and manage Instances
Here, in this post, I'll let you know how to use aws-cli to launch and manage AWS services with very ease.
Today, I will demonstrate how to do the following things:
1: Creating a key-pair
2: Creating a security-group
3: Launching an instance
4: Creating a Volume(EBS)
5: Attaching the EBS Volume to our AWS Instance
So Let's get started...
First of all you have to download and install aws-cli program in your computer.(NOTE: the link is for Windows OS only, you can search for other OS over the internet)
Now that you have aws-cli program in your computer, open cmd and run the command "aws" and you will get the screen something like this...
This means, that aws-cli is installed properly on your device. Now you have to configure your aws-cli, i.e., you have to login to your IAM role. After you login, we'll continue.
1: Creating a Key-Pair: You have to run the following command to create a key-pair
command: aws ec2 create-key-pay --key-name <keyname>
Confirming if the Keypair is created successfully using webUI
2: Creating a Security-Group:
command: aws ec2 create-security-group --group-name <groupname> --description <"description">
Confirming if the Security Group is created successfully using webUI
3: Launching an Instance with the above created key-pair and security-group:
command: aws ec2 run-instances --image-id <image-id> --instance-type <instance-type>--key-name <yourkeyname> --security-groups <your-security-groupname>
Confirming if the Instance is launched successfully using webUI
4: Creating a Volume(EBS):
command: aws ec2 create-volume --availability-zone <region/AZ-name> --size <inGB>
As you can see, the EBS volume is created. Don't confuse with the name "using-cli", I have given that name in the webUI itself so that we can easily identify.
Finally, now we will attach this EBS volume to our instance
- 5: Attaching the EBS Volume:AWS CLI Infrastructure and Using CMD to launch and manage Instances
For this you need to have your Volume ID, the Instance ID(because you need to confirm which instance you are going to attach this volume).
command: aws ec2 attach-volume --volume-id <yourVolumeID> --instance-id <yourInstanceID> --device /dev/xvda
Finally, we have learnt how to use aws-cli infrastructure and got to know how we can easily launch or manage services from AWS with the power of Command Line(and ofcourse that's what Computer Geeks use xD).