Simple Automation Tasks on AWS
Hi all, in this blog I will try to do some of the tasks in AWS using AWS-CLI as well as the use of Cloud formation.
- 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 I have created in the previous steps.
Here is the Youtube link for the demo version of the same
I have automated the above AWS tasks using Python Scripting using AWS-CLI.
You can refer to the code here for automation of the complete task.
https://github.com/Launchpad5682/ARTH-Tasks/tree/launchpad5682_branch/task-8/AWS
I have also done the same using Cloud Formation.
You can also find the code here
For the current Configuration:
- I am working in us-east-1 Region, I have taken the AMI-ID specific to that region for RHEL8 based instance since(Cloud formation is a regional service)
- I have opened ports for 22 and 80 for incoming traffic.
Note: if you want you can change the configuration according to your liking.
Upload the Template onto the Cloud Formation Service on the Management Console.
You can also view the Infrastructure in Design mode by clicking on View In Designer
Or you can go ahead and click on next
After you click on next , the next page you have to fill parameter details for
- Device: This is used for EBS Volume Device Mapping, when you associate a volume to a particular EC2 instance.
- KeyPair: Key pair will come according to the region in which you uplaoded the template.
Note: you can not create a new Key Pair through Cloud Formation. As Cloud formation has no way of storing the private key on your machine as a part of the stack initialization.
Click on next, and proceed to the Create Stack Option in the next Window
Now you’re stack would start to provision.
Head over to the Resources section to the check the different resources created.
Your Resources tab would be something like this, now you can click on the physical id, and it will take you to the respective Resources.
Here you can see an EC2 instance is created with the required security Group where I have opened port 22 and 80 for incoming traffic.
Here is the output of the 1 GB EBS volume that it attached to the EC2 instance
Thanks for reading, if you like it , do give it a clap :)
If you would like to learn more about Cloud formation, you can follow this github url