EC2: Auto-Scaling

EC2: Auto-Scaling

Β·

3 min read

🌟 Introduction

Automation, a capability of AWS Systems Manager, simplifies common maintenance, deployment, and remediation tasks for AWS services like Amazon Elastic Compute Cloud (Amazon EC2), Amazon Relational Database Service (Amazon RDS), Amazon Redshift, Amazon Simple Storage Service (Amazon S3), and many more.

Let's start with hands-on in which, I want to autoscale my instance. If the load increases at a particular limit or the instance is down for some reason, a new instance is created automatically.

πŸ“ Flow

  • Create Launch Template

  • Create Autoscaling group

πŸ“ Create a Launch Template for your instance

  • You can make a launch template with the configuration information you need to launch 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 launch template name, AMI ID, instance type, and network settings that you usually required to launch instances.

  • You can tell the Amazon EC2 console to use a certain launch template when you start an instance.

🌟 Task 1: Create a template

  • Go to the Launch template section in AWS and create a template.

  • Provide the AMI as Amazon Linux 2 as per project/requirement.

  • Provide the shape of the EC2 instance as per the required CPU and Memory, Create key pair for login to your instance.

  • Select the subnet and security group.

  • In the additional section, you can provide a shell script to install docker and Jenkins as pre-requisite to the server.

  • Now click to create a template and then navigate to the Action section to launch an instance out of the created template.

  • Provide the desired number of instances as shown.

  • Navigate to the instance section in the EC2 dashboard and the instances will be now created. Here we have created 3 instances.

🌟 Task 2: Create an Auto Scaling group

  • Navigate to the Autoscaling group section and give a name to the group that will be created. Select the template that we have created in the above task.

  • Provide the subnet you want to keep your servers at.

  • Provide the desired capacity and maximum capacity of the group to create servers.

  • Review and now create the group.

  • Now, navigate to the instance section and you can see 6 servers.

    Out of 6, 3 servers were created for above task 1 and the rest 3 are spun up by the Auto-Scaling group as the desired field we gave is 3.

🌟Conclusion:

In this article, we learn how to use a shell script to install docker, Jenkins in your instance automatically. By using the script we save some more time and increase efficiency. To scale up your instances you use autoscaling, which provides high availability, fault tolerance, managing different types of workloads and many more.

\...................................................................................................................................................

The above information is up to my understanding. Suggestions are always welcome. Thanks for reading this article.

#aws #EC2 #autoscaling #DevOps #TrainWithShubham #cloudcommunity

#90daysofdevops #devopscommunity #happylearning

Follow for many such contents:

LinkedIn: linkedin.com/in/dushyant-kumar-dk

Blog: dushyantkumark.hashnode.dev

Β