An open API service indexing awesome lists of open source software.

https://github.com/launchbynttdata/tf-aws-module_primitive-lb_target_group


https://github.com/launchbynttdata/tf-aws-module_primitive-lb_target_group

Last synced: 13 days ago
JSON representation

Awesome Lists containing this project

README

          

# tf-aws-module_primitive-lb_target_group

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License: CC BY-NC-ND 4.0](https://img.shields.io/badge/License-CC_BY--NC--ND_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc-nd/4.0/)

## Overview

This primitive Terraform module wraps a single `aws_lb_target_group` resource. It exposes every
documented argument so the target group can be used with any combination of Application,
Network, or Gateway Load Balancers and any supported `target_type`.

## Usage

See [`examples/complete`](./examples/complete) for a fully working example that creates a VPC and
an HTTPS Application Load Balancer target group with health checks, stickiness, and target group
health requirements.

## Pre-commit hooks

Install the [pre-commit](https://pre-commit.com/) framework and run `pre-commit install` from the
repository root. The hook configuration in [.pre-commit-config.yaml](.pre-commit-config.yaml) runs:

- `terraform fmt`, `terraform validate`, and `terraform-docs` against this module.
- `golangci-lint` against the test code.
- `commitlint` against commit messages.
- `detect-secrets` against staged files using the [.secrets.baseline](.secrets.baseline) file.

## Workflows

This repository ships with a single GitHub Actions workflow,
[`pull-request-terraform-check-aws.yml`](.github/workflows/pull-request-terraform-check-aws.yml),
which delegates to the reusable AWS Terraform check workflow in `launchbynttdata/launch-workflows`.

## Requirements

| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | ~> 1.10 |
| [aws](#requirement\_aws) | >= 5.0, < 7.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_lb_target_group.target_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [connection\_termination](#input\_connection\_termination) | Whether to terminate connections at the end of the deregistration timeout on Network Load Balancers. | `bool` | `false` | no |
| [deregistration\_delay](#input\_deregistration\_delay) | Amount of time (seconds) for ELB to wait before changing a deregistering target from draining to unused. Range is 0-3600. | `number` | `300` | no |
| [health\_check](#input\_health\_check) | Health check configuration block.
enabled = Whether health checks are enabled. Defaults to true.
healthy\_threshold = Successes required before considering a target healthy. Range 2-10. Defaults to 3.
unhealthy\_threshold = Failures required before considering a target unhealthy. Range 2-10. Defaults to 3.
interval = Seconds between health checks. Range 5-300. Defaults to 30.
timeout = Seconds before a no-response check is considered failed. Range 2-120.
protocol = Protocol for health checks. One of TCP, HTTP, HTTPS. Defaults to HTTP.
port = Port to use for health checks. "traffic-port" or 1-65535. Defaults to traffic-port.
path = HTTP/HTTPS health check destination path.
matcher = HTTP/gRPC codes for a successful response. |

object({
enabled = optional(bool)
healthy_threshold = optional(number)
unhealthy_threshold = optional(number)
interval = optional(number)
timeout = optional(number)
protocol = optional(string)
port = optional(string)
path = optional(string)
matcher = optional(string)
})
| `null` | no |
| [ip\_address\_type](#input\_ip\_address\_type) | Type of IP addresses used by the target group. Only valid when target\_type is ip. One of ipv4 or ipv6. | `string` | `null` | no |
| [lambda\_multi\_value\_headers\_enabled](#input\_lambda\_multi\_value\_headers\_enabled) | Whether request and response headers exchanged with the Lambda function include arrays of values or strings. Only applies when target\_type is lambda. | `bool` | `false` | no |
| [load\_balancing\_algorithm\_type](#input\_load\_balancing\_algorithm\_type) | Algorithm used by an ALB target group. One of round\_robin, least\_outstanding\_requests, or weighted\_random. Defaults to round\_robin. | `string` | `null` | no |
| [load\_balancing\_anomaly\_mitigation](#input\_load\_balancing\_anomaly\_mitigation) | Whether to enable target anomaly mitigation. Only supported with the weighted\_random algorithm. One of on or off. Defaults to off. | `string` | `null` | no |
| [load\_balancing\_cross\_zone\_enabled](#input\_load\_balancing\_cross\_zone\_enabled) | Whether cross zone load balancing is enabled. One of true, false, or use\_load\_balancer\_configuration. Defaults to use\_load\_balancer\_configuration. | `string` | `null` | no |
| [name](#input\_name) | Name of the target group. Must be unique per region per account, max 32 characters, alphanumeric or hyphens, must not begin or end with a hyphen. Conflicts with name\_prefix. | `string` | `null` | no |
| [name\_prefix](#input\_name\_prefix) | Prefix used to generate a unique target group name. Cannot be longer than 6 characters. Conflicts with name. | `string` | `null` | no |
| [port](#input\_port) | Port on which targets receive traffic. Required when target\_type is instance, ip, or alb. Does not apply when target\_type is lambda. | `number` | `null` | no |
| [preserve\_client\_ip](#input\_preserve\_client\_ip) | Whether client IP preservation is enabled. Defaults vary by target\_type and protocol; leave null to use AWS defaults. | `string` | `null` | no |
| [protocol](#input\_protocol) | Protocol used for routing traffic to the targets. One of GENEVE, HTTP, HTTPS, TCP, TCP\_UDP, TLS, UDP, QUIC, or TCP\_QUIC. Required when target\_type is instance, ip, or alb. | `string` | `null` | no |
| [protocol\_version](#input\_protocol\_version) | Protocol version. Only applicable when protocol is HTTP or HTTPS. One of HTTP1, HTTP2, or GRPC. Defaults to HTTP1. | `string` | `null` | no |
| [proxy\_protocol\_v2](#input\_proxy\_protocol\_v2) | Whether to enable support for proxy protocol v2 on Network Load Balancers. | `bool` | `false` | no |
| [slow\_start](#input\_slow\_start) | Amount of time (seconds) for targets to warm up before the load balancer sends them a full share of requests. Range is 30-900 seconds, or 0 to disable. | `number` | `0` | no |
| [stickiness](#input\_stickiness) | Stickiness configuration block.
type = (Required when set) lb\_cookie, app\_cookie, source\_ip, source\_ip\_dest\_ip, or source\_ip\_dest\_ip\_proto.
enabled = Whether stickiness is enabled. Defaults to true.
cookie\_duration = (lb\_cookie only) Seconds to retain affinity. Range 1-604800. Defaults to 86400.
cookie\_name = (app\_cookie only) Application cookie name. |
object({
type = string
enabled = optional(bool)
cookie_duration = optional(number)
cookie_name = optional(string)
})
| `null` | no |
| [tags](#input\_tags) | Map of tags to assign to the target group. | `map(string)` | `{}` | no |
| [target\_failover](#input\_target\_failover) | Target failover configuration. Only applicable for Gateway Load Balancer target groups.
on\_deregistration = rebalance or no\_rebalance. Must match on\_unhealthy.
on\_unhealthy = rebalance or no\_rebalance. Must match on\_deregistration. |
object({
on_deregistration = string
on_unhealthy = string
})
| `null` | no |
| [target\_group\_health](#input\_target\_group\_health) | Target group health requirements. Only supported by ALB and NLB target groups.
dns\_failover.minimum\_healthy\_targets\_count = "off" or integer 1 to max targets.
dns\_failover.minimum\_healthy\_targets\_percentage = "off" or integer 1-100.
unhealthy\_state\_routing.minimum\_healthy\_targets\_count = Integer 1 to max targets. Defaults to 1.
unhealthy\_state\_routing.minimum\_healthy\_targets\_percentage = "off" or integer 1-100. |
object({
dns_failover = optional(object({
minimum_healthy_targets_count = optional(string)
minimum_healthy_targets_percentage = optional(string)
}))
unhealthy_state_routing = optional(object({
minimum_healthy_targets_count = optional(string)
minimum_healthy_targets_percentage = optional(string)
}))
})
| `null` | no |
| [target\_health\_state](#input\_target\_health\_state) | Target health state configuration. Only applicable for NLB target groups with TCP or TLS protocol.
enable\_unhealthy\_connection\_termination = Whether the load balancer terminates connections to unhealthy targets. Defaults to true.
unhealthy\_draining\_interval = Time to wait for in-flight requests when a target becomes unhealthy. Range 0-360000. Defaults to 0. |
object({
enable_unhealthy_connection_termination = optional(bool)
unhealthy_draining_interval = optional(number)
})
| `null` | no |
| [target\_type](#input\_target\_type) | Type of target. One of instance, ip, lambda, or alb. Defaults to instance. | `string` | `"instance"` | no |
| [vpc\_id](#input\_vpc\_id) | Identifier of the VPC in which to create the target group. Required when target\_type is instance, ip, or alb. | `string` | `null` | no |

## Outputs

| Name | Description |
|------|-------------|
| [arn](#output\_arn) | The ARN of the target group. |
| [arn\_suffix](#output\_arn\_suffix) | The ARN suffix of the target group, for use with CloudWatch Metrics. |
| [id](#output\_id) | The ID of the target group (same as the arn). |
| [load\_balancer\_arns](#output\_load\_balancer\_arns) | ARNs of the load balancers associated with the target group. |
| [name](#output\_name) | The name of the target group. |
| [tags\_all](#output\_tags\_all) | Map of all tags assigned to the target group, including those inherited from provider default\_tags. |