The load balancer market-alb is up, with a listener on 80 forwarding to the target group web-tg, which checks /health. The security group web-sg lets the load balancer in. ~/app.sh installs the shop; building its catalogue takes about two minutes.
-
Keep the latest Amazon Linux image id in
AMI,web-sg's id inWEB_SG,web-tg's ARN inTG, and the subnets ofus-east-1aandus-east-1binSUBNET_AandSUBNET_B. -
A colleague tried to make the launch template
web-ltlike this, and it failed:shaws ec2 create-launch-template --launch-template-name web-lt --launch-template-data "ImageId=$AMI,InstanceType=t3.micro,SecurityGroupIds=$WEB_SG,UserData=$(cat app.sh)"Read the error, and create
web-ltfromapp.shproperly. -
They also wrote the group's command. Run it:
shaws autoscaling create-auto-scaling-group --auto-scaling-group-name web-asg --launch-template LaunchTemplateName=web-lt,Version='$Latest' --min-size 2 --max-size 4 --desired-capacity 2 --vpc-zone-identifier "$SUBNET_A,$SUBNET_B" --target-group-arns $TG --health-check-type ELB --tags Key=Name,Value=web,PropagateAtLaunch=true -
Over the next five minutes, list the group's instances and read its scaling activities. Find out why its instances keep being replaced, and fix the group so that a new instance has the time it needs.
-
Once both targets in
web-tgarehealthy, terminate one of the instances the group lists asInService, and watch the group replace it.