If you've applied the patterns and followed the practices enumerated here, you are on the road to success. Unfortunately, success often comes more swiftly than you expect. A mention on Hacker News, Reddit, or Twitter can send waves of traffic your way. Let's take a look at how Amazon's auto scaling feature can help us to meet the demand in a cost effective way. First, we will define a launch configuration for our product—this should go into the instanceAZ1c.tf
file:
resource "aws_launch_configuration" "asg_conf" { name = "book-asg-config" image_id = "ami-001e1c1159ccfe992" instance_type = "t2.micro" }
Then, add an autoscaling group to the same file, which encompasses all AZs, so that the workload gets distributed evenly:
resource "aws_autoscaling_group" "book_group" { availability_zones = ["us-east-1a","us-east-1b","us-east-1c"] name = "book-group-asg" max_size = 5 min_size = 2 health_check_grace_period = 300 health_check_type = "ELB" force_delete = true ...