9. Load Balancer & Auto Scaling Group

Finally, let's create a webserver cluster that will consist of:

  • an Application Load Balancer that will forward traffic to

  • a Target Group (collection of EC2 instances, built from custom AMI) managed by

  • an Auto Scaling Group

terraform/webserver-cluster/variables.tf
variable "server_port" {
  description = "The port the server will use for HTTP requests"
  type        = number
  default     = 8080
}

variable "cluster_min_size" {
  description = "Minimum number of EC2 instances in Auto Scaling Group"
  type        = number
  default     = 3
}

variable "cluster_max_size" {
  description = "Maximum number of EC2 instances in Auto Scaling Group"
  type        = number
  default     = 6
}

Apply.

Last updated

Was this helpful?