Auto scaling groups along with Launch Configurations enable you to create a logical group of EC2 instances that are always available.
ASGs optionally work with ELBs but ELB is not needed for ASG to work.
What is Launch Configuration?
Used by auto scaling group to launch EC2 instances without user intervention.
Is a recipe to create an EC2 instance. Steps involved are exactly same as creating an EC2 except at the end you will create the recipe as opposed to launching the actual instance.
Create Launch Configuration
Choose Instance Type
Name the launch config
Choose spot instances or not
Choose if you need detailed monitoring on cloud watch
Choose IAM roles if any
Input the User data (bootstrapping code) if any
Any ip address related parameters
Add storage details
Security Group details (default or your own)
Input your key pair name
Click save the launch configuration
Create Auto Scaling Group. (This will launch the EC2 instances)
Name of the auto scaling group
Choose Group size (starting number of instances)
Choose subnets (one or more. Its a multi select. Better to choose two or more AZs). The instances from above step will be distributed evenly among the chosen AZs
Choose Launch Configuration
Choose optional Load Balancer
Choose which health check to use (ELB or EC2)
Input health check grace period (300 sec default). This is the amount of time the ASG waits before it checks the health of a newly started instance. If you have major bootstrapping script, increase this parameter.
Scaling policies enable you to either keep the group size constant at th initial size or
Scale between min and max instances (min and max are not equal to initial size)
Increase Group Size Rule
Execute policy when (Points to an Alarm. Alarm has following)
Name of the alarm
Whenever: Average/Min/Max of CPU/RAM >/</>=/<= XXXX percent.
At least: N number of consecutive periods of T sec/min
Optional SNS notification
Take the action:
Warm up time (300 sec)
Similarly Create Decrease Group Size Rule
Provide optional email to be sent when launching/termination/fail to launch/fail to terminate instances
Finally click to “Create ASG”. This will immediately launch the EC2 instances as per the rules of the ASG
Remember: Security Group is input for the launch configuration whereas VPC/subnets/AZs are parameters of the auto scaling group.