Automation in EC2:
Amazon EC2 or Amazon Elastic Compute Cloud can give you secure, reliable, high-performance, and cost-effective computing infrastructure to meet demanding business needs.
Also, if you know a few things, you can automate many things.
Launch template in AWS EC2:
You can make a launch template with the configuration information you need to start an instance. You can save launch parameters in launch templates so you don't have to type them in every time you start a new instance.
For example, a launch template can have the AMI ID, instance type, and network settings that you usually use to launch instances.
You can tell the Amazon EC2 console to use a certain launch template when you start an instance.
Instance Types:
Amazon EC2 has a large number of instance types that are optimised for different uses. The different combinations of CPU, memory, storage and networking capacity in instance types give you the freedom to choose the right mix of resources for your apps. Each instance type comes with one or more instance sizes, so you can adjust your resources to meet the needs of the workload you want to run.
AMI:
An Amazon Machine Image (AMI) is an image that AWS supports and keeps up to date. It contains the information needed to start an instance. When you launch an instance, you must choose an AMI. When you need multiple instances with the same configuration, you can launch them from a single AMI.
Task1:
Create a launch template with Amazon Linux 2 AMI and t2.micro instance type with Jenkins and Docker setup (You can use the Day 39 User data script for installing the required tools.
Create 3 Instances using Launch Template.
- Create a launch template:
- Provide the AMI as Amazon Linux 2:
- Select Instance Type: t2.micro
- Select an existing security group or create one:
- Write a User Data script for Jenkins and Docker setup.
- Click the launch template and use the launched template to launch instances:
- Specify the number of instances you want to launch: Here I'm launching 3 instances:
- Click on Instances and you will see the launched instances:
You can go one step ahead and create an auto-scaling group.
Auto-Scaling Group:
An Auto Scaling Group (ASG) is a service offered by Amazon Web Services (AWS) that enables you to scale your Amazon EC2 (Elastic Compute Cloud) instances automatically based on defined conditions. The primary purpose of an Auto Scaling Group is to ensure that you have a specified number of instances running to handle the load for your application.
- Go to the Auto Scaling Section to create an Auto Scaling Group using the launch template that was just created:
- Select availability zones and subnets:
- Configure the desired capacity and scaling policies:
- Review and click "Create auto-scaling group"
- Then, click on "Instances"
Here, there are 5 Instances, 3 were created from the first task and the remaining 2 were created by the auto-scaling group because in the desired capacity I specified 2.
...