Skip to content

A Terraform module to manage an Elastic Load Balancing (ELB) Target Group on Amazon Web Services (AWS). https://aws.amazon.com/elasticloadbalancing

License

Notifications You must be signed in to change notification settings

serviceright/terraform-aws-lb-target-group

 
 

Repository files navigation

Build Status GitHub tag (latest SemVer) Terraform Version AWS Provider Version Join Slack

terraform-aws-lb-target-group

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

This module implements the following Terraform resources:

  • aws_lb_target_group

Getting Started

Most common usage of the module:

module "terraform-aws-lb-target-group" {
  source = "git@github.com:mineiros-io/terraform-aws-lb-target-group.git?ref=v0.0.1"
}

Module Argument Reference

See variables.tf and examples/ for details and use-cases.

Main Resource Configuration

  • name_prefix: (Optional string)

    Creates a unique name beginning with the specified prefix. Conflicts with name. Cannot be longer than 6 characters. Forces new resource.

  • name: (Optional string)

    Name of the target group. If omitted, Terraform will assign a random, unique name. Forces new resource.

  • target_type: (Optional string)

    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) or ip (targets are specified by IP address) or lambda (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 is ip, 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: (Optional number)

    Port on which targets receive traffic, unless overridden when registering a specific target. Required when target_type is instance or ip. Does not apply when target_type is lambda.

  • protocol: (Optional string)

    Protocol to use for routing traffic to the targets. Should be one of GENEVE, HTTP, HTTPS, TCP, TCP_UDP, TLS, or UDP. Required when target_type is instance, ip or alb. Does not apply when target_type is lambda.

  • protocol_version: (Optional string)

    Only applicable when protocol is HTTP or HTTPS. The protocol version. Specify GRPC to send requests to targets using gRPC. Specify HTTP2 to send requests to targets using HTTP/2. The default is HTTP1, which sends requests to targets using HTTP/1.1

    Default is "HTTP1".

  • preserve_client_ip: (Optional bool)

    Whether client IP preservation is enabled.

  • lambda_multi_value_headers_enabled: (Optional bool)

    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 is lambda.

  • load_balancing_algorithm_type: (Optional bool)

    Determines how the load balancer selects targets when routing requests. Only applicable for Application Load Balancer Target Groups. The value is round_robin or least_outstanding_requests.

  • health_check: (Optional object(health_check))

    Health check configuration block.

    The health_check object accepts the following attributes:

    • enabled: (Optional bool)

      Whether health checks are enabled.

      Default is true.

    • healthy_threshold: (Optional number)

      Number of consecutive health checks successes required before considering an unhealthy target healthy.

    • interval: (Optional number)

      Approximate amount of time, in seconds, between health checks of an individual target. Minimum value 5 seconds, Maximum value 300 seconds. For lambda target groups, it needs to be greater as the timeout of the underlying lambda.

    • matcher: (Optional string)

      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: (Optional string)

      Destination for the health check request. Required for HTTP/HTTPS ALB and HTTP NLB. Only applies to HTTP/HTTPS.

    • port: (Optional string)

      Port to use to connect with the target. Valid values are either ports 1-65535, or traffic-port.

    • protocol: (Optional string)

      Protocol to use to connect with the target.

    • timeout: (Optional number)

      Amount of time, in seconds, during which no response means a failed health check. For Application Load Balancers, the range is 2 to 120 seconds, and the default is 5 seconds for the instance target type and 30 seconds for the lambda target type. For Network Load Balancers, you cannot set a custom value, and the default is 10 seconds for TCP and HTTPS health checks and 6 seconds for HTTP health checks.

    • unhealthy_threshold: (Optional number)

      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: (Optional object(stickiness))

    Stickiness configuration block.

    The stickiness object accepts the following attributes:

    • enabled: (Optional bool)

      Boolean to enable / disable stickiness.

      Default is true.

    • type: (Optional string)

      The type of sticky sessions. The only current possible values are lb_cookie, app_cookie for ALBs, and source_ip for NLBs.

    • cookie_name: (Optional string)

      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: (Required number)

      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 is 1 second to 1 week (604800 seconds).

  • vpc_id: (Optional string)

    Identifier of the VPC in which to create the target group. Required when target_type is instance, ip or alb. Does not apply when target_type is lambda.

  • deregistration_delay: (Optional number)

    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: (Optional map(string))

    A map of tags to apply to the created load balancer target group.

    Default is {}.

Module Configuration

  • module_enabled: (Optional bool)

    Specifies whether resources in the module will be created.

    Default is true.

  • module_tags: (Optional map(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: (Optional list(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
    ]

Module Outputs

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.

External Documentation

AWS Documentation

Terraform AWS Provider Documentation

Module Versioning

This Module follows the principles of Semantic Versioning (SemVer).

Given a version number MAJOR.MINOR.PATCH, we increment the:

  1. MAJOR version when we make incompatible changes,
  2. MINOR version when we add functionality in a backwards compatible manner, and
  3. PATCH version when we make backwards compatible bug fixes.

Backwards compatibility in 0.0.z and 0.y.z version

  • Backwards compatibility in versions 0.0.z is not guaranteed when z is increased. (Initial development)
  • Backwards compatibility in versions 0.y.z is not guaranteed when y is increased. (Pre-release)

About Mineiros

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 hello@mineiros.io or join our Community Slack channel.

Reporting Issues

We use GitHub Issues to track community reported issues and missing features.

Contributing

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.

Makefile Targets

This repository comes with a handy Makefile. Run make help to see details on each available target.

License

license

This module is licensed under the Apache License Version 2.0, January 2004. Please see LICENSE for full details.

Copyright © 2020-2022 Mineiros GmbH

About

A Terraform module to manage an Elastic Load Balancing (ELB) Target Group on Amazon Web Services (AWS). https://aws.amazon.com/elasticloadbalancing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 68.3%
  • Makefile 19.2%
  • Go 12.5%