A Terraform module to create and manage an Amazon Load Balancer Target Group on Amazon Web Services (AWS).
This module supports Terraform version 1 and is compatible with the Terraform AWS Provider version 3.47.
This module is part of our Infrastructure as Code (IaC) framework that enables our users and customers to easily deploy and manage reusable, secure, and production-grade cloud infrastructure.
- Module Features
- Getting Started
- Module Argument Reference
- Module Outputs
- External Documentation
- Module Versioning
- About Mineiros
- Reporting Issues
- Contributing
- Makefile Targets
- License
This module implements the following Terraform resources:
aws_lb_target_group
Most common usage of the module:
module "terraform-aws-lb-target-group" {
source = "[email protected]:mineiros-io/terraform-aws-lb-target-group.git?ref=v0.0.1"
}
See variables.tf and examples/ for details and use-cases.
-
name_prefix
: (Optionalstring
)Creates a unique name beginning with the specified prefix. Conflicts with
name
. Cannot be longer than 6 characters. Forces new resource. -
name
: (Optionalstring
)Name of the target group. If omitted, Terraform will assign a random, unique name. Forces new resource.
-
target_type
: (Optionalstring
)Type of target that you must specify when registering targets with this target group. The possible values are
instance
(targets are specified by instance ID) orip
(targets are specified by IP address) orlambda
(targets are specified by lambda arn). Note that you can't specify targets for a target group using both instance IDs and IP addresses. If the target type isip
, specify IP addresses from the subnets of the virtual private cloud (VPC) for the target group. You can't specify publicly routable IP addresses. -
port
: (Optionalnumber
)Port on which targets receive traffic, unless overridden when registering a specific target. Required when
target_type
isinstance
orip
. Does not apply whentarget_type
islambda
. -
protocol
: (Optionalstring
)Protocol to use for routing traffic to the targets. Should be one of
GENEVE
,HTTP
,HTTPS
,TCP
,TCP_UDP
,TLS
, orUDP
. Required whentarget_type
is instance,ip
oralb
. Does not apply whentarget_type
islambda
. -
protocol_version
: (Optionalstring
)Only applicable when protocol is
HTTP
orHTTPS
. The protocol version. SpecifyGRPC
to send requests to targets using gRPC. SpecifyHTTP2
to send requests to targets usingHTTP/2
. The default is HTTP1, which sends requests to targets using HTTP/1.1Default is
"HTTP1"
. -
preserve_client_ip
: (Optionalbool
)Whether client IP preservation is enabled.
-
lambda_multi_value_headers_enabled
: (Optionalbool
)Whether the request and response headers exchanged between the load balancer and the Lambda function include arrays of values or strings. Only applies when
target_type
islambda
. -
load_balancing_algorithm_type
: (Optionalbool
)Determines how the load balancer selects targets when routing requests. Only applicable for Application Load Balancer Target Groups. The value is
round_robin
orleast_outstanding_requests
. -
health_check
: (Optionalobject(health_check)
)Health check configuration block.
The
health_check
object accepts the following attributes:-
enabled
: (Optionalbool
)Whether health checks are enabled.
Default is
true
. -
healthy_threshold
: (Optionalnumber
)Number of consecutive health checks successes required before considering an unhealthy target healthy.
-
interval
: (Optionalnumber
)Approximate amount of time, in seconds, between health checks of an individual target. Minimum value
5
seconds, Maximum value300
seconds. For lambda target groups, it needs to be greater as the timeout of the underlying lambda. -
matcher
: (Optionalstring
)Response codes to use when checking for a healthy responses from a target. You can specify multiple values (for example,
"200,202"
for HTTP(s) or"0,12"
for GRPC) or a range of values (for example,"200-299"
or"0-99"
). Required for HTTP/HTTPS/GRPC ALB. Only applies to Application Load Balancers (i.e., HTTP/HTTPS/GRPC) not Network Load Balancers (i.e., TCP). -
path
: (Optionalstring
)Destination for the health check request. Required for HTTP/HTTPS ALB and HTTP NLB. Only applies to HTTP/HTTPS.
-
port
: (Optionalstring
)Port to use to connect with the target. Valid values are either ports
1
-65535
, ortraffic-port
. -
protocol
: (Optionalstring
)Protocol to use to connect with the target.
-
timeout
: (Optionalnumber
)Amount of time, in seconds, during which no response means a failed health check. For Application Load Balancers, the range is
2
to120
seconds, and the default is5
seconds for the instance target type and30
seconds for the lambda target type. For Network Load Balancers, you cannot set a custom value, and the default is10
seconds for TCP and HTTPS health checks and6
seconds for HTTP health checks. -
unhealthy_threshold
: (Optionalnumber
)Number of consecutive health check failures required before considering the target unhealthy. For Network Load Balancers, this value must be the same as the
healthy_threshold
.
-
-
stickiness
: (Optionalobject(stickiness)
)Stickiness configuration block.
The
stickiness
object accepts the following attributes:-
enabled
: (Optionalbool
)Boolean to enable / disable stickiness.
Default is
true
. -
type
: (Optionalstring
)The type of sticky sessions. The only current possible values are
lb_cookie
,app_cookie
for ALBs, andsource_ip
for NLBs. -
cookie_name
: (Optionalstring
)Name of the application based cookie. AWSALB, AWSALBAPP, and AWSALBTG prefixes are reserved and cannot be used. Only needed when type is
app_cookie
. -
cookie_duration
: (Requirednumber
)Only used when the type is
lb_cookie
. 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 is1
second to 1 week (604800
seconds).
-
-
vpc_id
: (Optionalstring
)Identifier of the VPC in which to create the target group. Required when
target_type
isinstance
,ip
oralb
. Does not apply whentarget_type
islambda
. -
deregistration_delay
: (Optionalnumber
)Amount time for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused. The range is
0
-3600
seconds.Default is
300
. -
tags
: (Optionalmap(string)
)A map of tags to apply to the created load balancer target group.
Default is
{}
.
-
module_enabled
: (Optionalbool
)Specifies whether resources in the module will be created.
Default is
true
. -
module_tags
: (Optionalmap(string)
)A map of tags that will be applied to all created resources that accept tags. Tags defined with
module_tags
can be overwritten by resource-specific tags.Default is
{}
.Example:
module_tags = { environment = "staging" team = "platform" }
-
module_depends_on
: (Optionallist(dependency)
)A list of dependencies. Any object can be assigned to this list to define a hidden external dependency.
Default is
[]
.Example:
module_depends_on = [ null_resource.name ]
The following attributes are exported in the outputs of the module:
-
lb_target_group
: (object(lb_target_group)
)All outputs of the created
aws_lb_target_group
resource. -
module_enabled
: (bool
)Whether this module is enabled.
-
module_tags
: (map(string)
)The map of tags that are being applied to all created resources that accept tags.
- Application Load Balancer: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html
- Network Load Balancer: https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html
This Module follows the principles of Semantic Versioning (SemVer).
Given a version number MAJOR.MINOR.PATCH
, we increment the:
MAJOR
version when we make incompatible changes,MINOR
version when we add functionality in a backwards compatible manner, andPATCH
version when we make backwards compatible bug fixes.
- Backwards compatibility in versions
0.0.z
is not guaranteed whenz
is increased. (Initial development) - Backwards compatibility in versions
0.y.z
is not guaranteed wheny
is increased. (Pre-release)
Mineiros is a remote-first company headquartered in Berlin, Germany that solves development, automation and security challenges in cloud infrastructure.
Our vision is to massively reduce time and overhead for teams to manage and deploy production-grade and secure cloud infrastructure.
We offer commercial support for all of our modules and encourage you to reach out if you have any questions or need help. Feel free to email us at [email protected] or join our Community Slack channel.
We use GitHub Issues to track community reported issues and missing features.
Contributions are always encouraged and welcome! For the process of accepting changes, we use Pull Requests. If you'd like more information, please see our Contribution Guidelines.
This repository comes with a handy Makefile.
Run make help
to see details on each available target.
This module is licensed under the Apache License Version 2.0, January 2004. Please see LICENSE for full details.
Copyright © 2020-2022 Mineiros GmbH