Operating AWS using CLI
In order to automate, we need to use the CLI commands. Knowing how to use AWS from command line interface is thus essential if we want to automate or create anything using it’s enormous power.
I’ve concentrated more on the approach of learning how to find the commands behind:
- Creating a key pair
- Creating a security group
- Launching an instance using the above two
- Creating an EBS volume of 1 GB
- Attaching the EBS volume to the above instance
The first step was, using GUI to explore AWS and understand the arrangement of services and their subservices, in order to understand the order of commands and options for the CLI approach.
I started by making an IAM user using GUI and configuring AWS console installed on my command prompt.
- This was followed by creating the key pair using “aws create-key-pair — key-name <name>” command.
We got the output as shown in the pic, this confirmed that the key has been successfully created.
2. The creation of security group was done using “aws ec2 create-security-group — group-name <name> — description <desc>” and the output confirmed it’s creation.
3. Launching an instance using the above key and security group was done using the elaborate command shown in the image. It follows the logic of our clicks, starting from EC2 service, followed by determining the image id, instance type, number of instances, subnet, security group id and key name we created above.
4. Creation of an Elastic Block Storage Volume of 1 GB was again done by following the steps of clicks in GUI.
5. Attaching the EBS Volume to the instance using the command shown in the pic.
As a practice, I like to detach and delete the created services after its usage, in order to avoid getting billed due to any mistakes. I’ve done so as follows:
Hope this article was useful!
I would like to thank Mr. Vimal Daga, for teaching the approach to learning in such an effective way.