How to Configure Launch Configuration & Auto Scaling
Through a launch configuration we can create a template for EC2 instances that have the same predefined configuration. EC2 instances can be created when more instances are required for load balancing from this configuration.
- Create a launch configuration of Linus Free Tier of your Choice
- Select No public IP to be assigned to any instance
- Select the SG which can provide access to SSH and HTTP protocols ( SG which was created earlier )
- Use dclessons-new-key.pub as key pair and create the launch configuration.
- Create the Auto Scaling group using this Launch configuration name would be DCLESSONS-AUTO-SCALE
- Take size as 1 and select both public and private subnets as created earlier.
- Configure the following scaling size : Name DCLESSONS-SCALING-SIZE , SCALE Between 1-3 instances , In increase group Size use name DCLESSONS-GROUP-SIZE , execute the policy ALARM is selected.
- Configure the Following ALARM policies : CPU utilization is Average >=80 for atleast 10 mints
Browse to Launch Configurations under AUTO SCALING in the left menu bar. You’ll see the following dashboard if there are no Auto Scaling Groups or launch configurations already created:
You will be taken through the same steps that you did while creating an EC2 instance. Select your favourite AMI by clicking on Select as shown following as per task .
Click Next: Configure details. Provide the Name. Click on the Advanced Details and put the following lines in the textbox. It will install Apache, PHP, and MySQL in the server. It will also start the Apache server once the EC2 is running:
In the IP Address Type, choose the option Do not assign a public IP address to any instances, as we want to access the instances only through the load balancer. Click on Next: Add Storage. Leave the default options for now. Click on Next: Configure Security Group select the previous SG created.
Click on Review. You can review and modify configurations of the previous steps. Click on Create launch configuration:
Choose a key if you want to connect to the EC2 instance
Once launch configuration is done , select the option shown in below figure.
Provide a name in Group name DCLESSONS-AUTO-SCALE and Group size 1 to create the minimum number of instances in the group. Select VPC DCLESSONS-VPC in the Network option and one or more subnets to provide the AWS information about where these instances will be created. Leave the Advanced Details as they are. Click Next: Configure scaling policies. You should choose the same VPC with which the Security Group of the launch configuration is associated
Configure following AUTO Scaling group policy and alarm. Configure the following scaling size : Name DCLESSONS-SCALING-SIZE , SCALE Between 1-3 instances , In increase group Size use name DCLESSONS-GROUP-SIZE , execute the policy ALARM is selected. Configure the Following ALARM policies : CPU utilization is Average >=80 for atleast 10 mints
Provide firstname.lastname@example.org as send and receive notification and click on configure Tags where ,and use the following value as shown .
Now review the configuration and click on create the auto scaling group.