Load Balancer Target Group Module
View SourceRelease NotesThis module can be used to create a Target Group and Listener Rules for an Application Load Balancer created with the alb module.
The reason the load-balancer-alb-target-group module is separate is that you may wish to create multiple target groups
for a single load balancer.
See the examples folder for fully working sample code.
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S LOAD-BALANCER-ALB-TARGET-GROUP MODULE
# ------------------------------------------------------------------------------------------------------
module "load_balancer_alb_target_group" {
source = "git::git@github.com:gruntwork-io/terraform-aws-elk.git//modules/load-balancer-alb-target-group?ref=v0.11.1"
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# The path to use for health check requests.
health_check_path = <INPUT REQUIRED>
# The starting priority for the Listener Rules
listener_rule_starting_priority = <INPUT REQUIRED>
# The port the servers are listening on for requests.
port = <INPUT REQUIRED>
# The name to use for the Target Group
target_group_name = <INPUT REQUIRED>
# Whether we're using an ASG or Gruntwork's Server Group module. If using ASG,
# then var.asg_name must be specified. Otherwise leave it blank
using_server_group = <INPUT REQUIRED>
# The ID of the VPC in which to deploy the Target Group
vpc_id = <INPUT REQUIRED>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# The name of the ASG (ASG) in the servers are deployed. Leave this blank if using
# with a Server Group
asg_name = null
# The amount time for the Load Balancer to wait before changing the state of a
# deregistering server from draining to unused. The range is 0-3600 seconds.
deregistration_delay = 300
# Set to true to enable stickiness, so a given user always gets routed to the same
# server. We recommend enabling this for the Couchbase Web Console.
enable_stickiness = false
# The number of times the health check must pass before a server is considered
# healthy.
health_check_healthy_threshold = 2
# The approximate amount of time, in seconds, between health checks of each
# server. Minimum value 5 seconds, Maximum value 300 seconds.
health_check_interval = 30
# The HTTP codes to use when checking for a successful response from a server. You
# can specify multiple comma-separated values (for example, "200,202") or a range
# of values (for example, "200-299").
health_check_matcher = "200"
# The amount of time, in seconds, during which no response from a server means a
# failed health check. Must be between 2 and 60 seconds.
health_check_timeout = 5
# The number of times the health check must fail before a server is considered
# unhealthy.
health_check_unhealthy_threshold = 2
# The HTTP ARNs of ALB listeners to which Listener Rules that route to this Target
# Group should be added.
http_listener_arns = []
# The HTTPS ARNs of ALB listeners to which Listener Rules that route to this
# Target Group should be added.
https_listener_arns = []
# The number of HTTP ARNs in var.listener_arns. We should be able to compute this
# automatically, but due to a Terraform limitation, if there are any dynamic
# resources in var.listener_arns, then we won't be able to:
# https://github.com/hashicorp/terraform/pull/11482
num_http_listener_arns = 0
# The number of HTTPS ARNs in var.listener_arns. We should be able to compute this
# automatically, but due to a Terraform limitation, if there are any dynamic
# resources in var.listener_arns, then we won't be able to:
# https://github.com/hashicorp/terraform/pull/11482
num_https_listener_arns = 0
# The protocol to use to talk to the servers. Must be one of: HTTP, HTTPS.
protocol = "HTTP"
# This variable defines the paths or domain names that will be routed to the
# servers. By default, we route all paths and domain names to the servers. To
# override this, you should pass in a list of maps, where each map has the keys
# field and values. See the Condition Blocks documentation for the syntax to use:
# https://www.terraform.io/docs/providers/aws/r/lb_listener_rule.html.
routing_condition = [{"field":"path-pattern","values":["*"]}]
# The time period, in seconds, during which requests from a client should be
# routed to the same target. After this time period expires, the load
# balancer-generated cookie is considered stale. The range is 1 second to 1 week
# (604800 seconds). Only used if var.enable_stickiness is true.
stickiness_cookie_duration = 86400
}
# Coming soon!
Reference
- Inputs
- Outputs
Required
health_check_pathstringThe path to use for health check requests.
The starting priority for the Listener Rules
portnumberThe port the servers are listening on for requests.
target_group_namestringThe name to use for the Target Group
Whether we're using an ASG or Gruntwork's Server Group module. If using ASG, then asg_name must be specified. Otherwise leave it blank
vpc_idstringThe ID of the VPC in which to deploy the Target Group
Optional
asg_namestringThe name of the ASG (ASG) in the servers are deployed. Leave this blank if using with a Server Group
nullderegistration_delaynumberThe amount time for the Load Balancer to wait before changing the state of a deregistering server from draining to unused. The range is 0-3600 seconds.
300Set to true to enable stickiness, so a given user always gets routed to the same server. We recommend enabling this for the Couchbase Web Console.
falseThe number of times the health check must pass before a server is considered healthy.
2health_check_intervalnumberThe approximate amount of time, in seconds, between health checks of each server. Minimum value 5 seconds, Maximum value 300 seconds.
30health_check_matcherstringThe HTTP codes to use when checking for a successful response from a server. You can specify multiple comma-separated values (for example, '200,202') or a range of values (for example, '200-299').
"200"health_check_timeoutnumberThe amount of time, in seconds, during which no response from a server means a failed health check. Must be between 2 and 60 seconds.
5The number of times the health check must fail before a server is considered unhealthy.
2http_listener_arnslist(string)The HTTP ARNs of ALB listeners to which Listener Rules that route to this Target Group should be added.
[]https_listener_arnslist(string)The HTTPS ARNs of ALB listeners to which Listener Rules that route to this Target Group should be added.
[]num_http_listener_arnsnumberThe number of HTTP ARNs in listener_arns. We should be able to compute this automatically, but due to a Terraform limitation, if there are any dynamic resources in listener_arns, then we won't be able to: https://github.com/hashicorp/terraform/pull/11482
0num_https_listener_arnsnumberThe number of HTTPS ARNs in listener_arns. We should be able to compute this automatically, but due to a Terraform limitation, if there are any dynamic resources in listener_arns, then we won't be able to: https://github.com/hashicorp/terraform/pull/11482
0protocolstringThe protocol to use to talk to the servers. Must be one of: HTTP, HTTPS.
"HTTP"routing_conditionlist(object(…))This variable defines the paths or domain names that will be routed to the servers. By default, we route all paths and domain names to the servers. To override this, you should pass in a list of maps, where each map has the keys field and values. See the Condition Blocks documentation for the syntax to use: https://www.terraform.io/docs/providers/aws/r/lb_listener_rule.html.
list(object({
field = string
values = list(string)
}))
[
{
field = "path-pattern",
values = [
"*"
]
}
]
The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the load balancer-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds). Only used if enable_stickiness is true.
86400