One of the benefits of using cloud infrastructure is the ability to deploy and scale up or down really easily. Auto scaling in AWS EC2 allows you to flex your infrastructure based on demand. You are also able to include auto scaling groups in AWS CloudFormation templates.

This tutorial is going to walk you through the configuration of auto scaling and to test it actually works. Although configuring auto scaling is fairly simple once you know how to do it there are a series of steps you need to do in order and I will cover those off here.

Step 1: Build an EC2 instance and create an Amazon Machine Image (AMI)

I wanted to create a very quick instance and image for this tutorial. If you are going to follow the steps with me this is what you need to do…

  • Click “Launch Instance
  • On Step 1: Select “Ubuntu Server 20.04 LTS (HVM), SSD Volume Type
  • On Step 2: Select t2.micro (free-tier)
  • On Step 3: Make sure “Auto-assign Public IP” is set to “Enable
  • On Step 3: Include this provisioning script under “Advanced Details”, “User data”:
#!/bin/bash

apt-get update -y
apt-get upgrade -y
apt-get install apache2 stress -y
systemctl start apache2
systemctl enable --now apache2

Installing “stress” is important for this tutorial but normally you wouldn’t include it. It will allow you to stress the instance to allow the auto scaling to trigger.

Although I have not used it myself I know Netflix have their own stress testing tool called “Chaos Monkey”. It looks pretty interesting and worth checking out.

  • Steps 4 and 5: Leave defaults
  • Step 6: Create a security group called “acl-web-in” with the same description. Leave the default SSH rule in to allow you to access your instance but add an HTTP rule as well.

#tutorial #ec2 #autoscaling #aws #cloud-computing

Implementing and Testing AWS EC2 Auto Scaling
1.25 GEEK