Goal of a AWS ASG (Auto Scaling Group):
It helps in doing the Scale Out and Scale In of EC2 instances as per the load.
It also ensures we have a minimum and a maximum number of EC2 instances running.
Automatically registers a new instance to a Load Balancer.
Re-create a new EC2 instance if the previous one is terminated (eg.: if unhealthy).
ASG is free, you only have to pay the underlying EC2 instances.
To launch a AWS ASG you have to take help of something that is called Launch Template (Launch Configurations are deprecated) where you have to give below information:
- AMI + instance type
- EC2 user data
- EBS volumes
- Security Groups
- SSH key pair
- IAM roles for your instance types
- Network + subnets info
- Load Balancer info
- Min size/Max size/Initial capacity
- Scaling policies (Its possible to Scale In/Out based on some CloudWatch alarms)
Steps for creating an ASG on AWS:
Click “Auto Scaling Group” in the left panel:
Then give a name to it and choose required fields. The options are fairly similar the way you create an EC2 instance.
Now we will configure a Load Balancer, although its optional.
Configure group size and scaling policies.
Add tags, if any.
Review everything and click “Create Auto Scaling Group“.