AWS EC2 Automation ☁ AWS 😍

Β·

3 min read

AWS EC2 Automation ☁
AWS 😍

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.

Task

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

    Step 1: Create a Launch template with a version description

    Step 2: Select an AWS Linux 2 Ami.

    Step 3: Choose the t2.micro instance type.

    Step 4: Select the existing or create a new security group where mention 8080 port inbound rule.

    Step 5: Use the user data in advanced detail to automate the Docker and Jenkins installation for your instances.

    Step 6: Finally the launch template is created.

  2. Create 3 Instances using Launch Template, there must be an option that shows the number of instances to be launched, can you find it? :)

    Step 1: Go to Actions in (Step 6) where select launch instance from launch template

    Step 2: Thus the 3 instances can be launched using the launch template.

  3. You can go one step ahead and create an auto-scaling group, sounds tough?

    Step 1: Create an autoscaling group say ASG-1 and choose the launch template DevOps-template. Then go to next.

    Step 2: Select the default VPC and all available Availability Zones for easier scaling, and then click on Next.

    Step 3: Select the load balancer to distribute incoming traffic for your application across instances, ensuring ease of scaling and reliability. Additionally, create a target group for the load balancer as demonstrated below, and then click on next.

    Step 4: Select the group size and scaling policy according to your preference.

    Step 5: Thus, we create an autoscaling group where we ensure that the minimum desired capacity of instances is initialized. It will automatically scale and balance the incoming traffic based on CPU utilization.

    If the CPU utilization exceeds 50, instances will be added towards the maximum capacity and vice-versa. This demonstrates the autoscaling rebalancing feature.

That's all!! Hope it will help you as well.

References

Automation in EC2

Launch template in AWS EC2

Instance Types

Creating a launch template


Thanks for reading my articles.

Keep reading, motivating and upskilling.

Peace out!

Β