https://github.com/nventive/terraform-aws-lb
Terraform module to provision an Application, Network or Gateway Load Balancer.
https://github.com/nventive/terraform-aws-lb
Last synced: about 1 month ago
JSON representation
Terraform module to provision an Application, Network or Gateway Load Balancer.
- Host: GitHub
- URL: https://github.com/nventive/terraform-aws-lb
- Owner: nventive
- License: apache-2.0
- Created: 2023-09-28T14:40:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-24T14:33:53.000Z (over 2 years ago)
- Last Synced: 2025-03-04T09:40:00.290Z (over 1 year ago)
- Language: HCL
- Homepage: https://www.nventive.com
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# terraform-aws-lb
[](LICENSE) [](https://github.com/nventive/terraform-aws-lb/releases/latest)
Terraform module to provision an Application, Network or Gateway Load Balancer.
---
## Examples
**IMPORTANT:** We do not pin modules to versions in our examples because of the difficulty of keeping the versions in
the documentation in sync with the latest released versions. We highly recommend that in your code you pin the version
to the exact version you are using so that your infrastructure remains stable, and update versions in a systematic way
so that they do not catch you by surprise.
```hcl
module "alb" {
source = "nventive/lb/aws"
# We recommend pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "test"
name = "app"
load_balancer_type = "application"
}
```
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.2.0 |
| [aws](#requirement\_aws) | >= 4.9 |
| [null](#requirement\_null) | >= 3.0 |
| [random](#requirement\_random) | >= 3.0 |
| [time](#requirement\_time) | >= 0.7 |
## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | >= 4.9 |
| [null](#provider\_null) | >= 3.0 |
## Modules
| Name | Source | Version |
|------|--------|---------|
| [access\_logs](#module\_access\_logs) | cloudposse/lb-s3-bucket/aws | 0.19.0 |
| [sg](#module\_sg) | cloudposse/security-group/aws | 2.2.0 |
| [this](#module\_this) | cloudposse/label/null | 0.25.0 |
## Resources
| Name | Type |
|------|------|
| [aws_lb.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb) | resource |
| [null_resource.sg_vpc_validation](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [access\_logs\_enabled](#input\_access\_logs\_enabled) | Whether or not ALB access logs should be enabled. | `bool` | `true` | no |
| [access\_logs\_force\_destroy](#input\_access\_logs\_force\_destroy) | Set to `true` to force access logs bucket. | `bool` | `false` | no |
| [access\_logs\_prefix](#input\_access\_logs\_prefix) | Prefix for ALB access logs. | `string` | `""` | no |
| [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
| [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the `delimiter`
and treated as a single ID element. | `list(string)` | `[]` | no |
| [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
} | no |
| [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
| [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
| [enable\_deletion\_protection](#input\_enable\_deletion\_protection) | If true, deletion of the load balancer will be disabled via the AWS API. This will prevent Terraform from deleting the load balancer. | `bool` | `false` | no |
| [enable\_http2](#input\_enable\_http2) | Indicates whether HTTP/2 is enabled in `application` load balancers. | `bool` | `false` | no |
| [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
| [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
| [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no |
| [idle\_timeout](#input\_idle\_timeout) | The time in seconds that the connection is allowed to be idle. Only valid for Load Balancers of type `application`. | `number` | `60` | no |
| [internal](#input\_internal) | Set to `true`, to create an internal Load Balancer. | `bool` | `false` | no |
| [ip\_address\_type](#input\_ip\_address\_type) | Address type for ALB possible. Specify one of `ipv4`, `dualstack`. | `string` | `null` | no |
| [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no |
| [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
| [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no |
| [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.
Default is to include all labels.
Tags with empty values will not be included in the `tags` output.
Set to `[]` to suppress all generated tags.
**Notes:**
The value of the `name` tag, if included, will be the `id`, not the `name`.
Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | [
"default"
]
| no |
| [load\_balancer\_type](#input\_load\_balancer\_type) | Type of the Load Balancer. Specify one of `application`, `network` or `gateway`. | `string` | `"application"` | no |
| [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
| [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
| [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| [security\_group\_enabled](#input\_security\_group\_enabled) | Set to `true` to create a self-referencing security group for all ports. | `bool` | `false` | no |
| [security\_group\_ids](#input\_security\_group\_ids) | Security group IDS to associate with the Load Balancer. | `list(string)` | `[]` | no |
| [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| [subnet\_ids](#input\_subnet\_ids) | List of subnet IDs for the Load Balancer. The Load Balancer will be created in the VPC associated with the subnet IDs. | `list(string)` | `[]` | no |
| [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
| [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
| [vpc\_id](#input\_vpc\_id) | ID of the VPC. Required if `security_group_enabled` is `true`. | `string` | `null` | no |
## Outputs
| Name | Description |
|------|-------------|
| [access\_logs\_bucket\_arn](#output\_access\_logs\_bucket\_arn) | Access Logs S3 bucket ARN. |
| [access\_logs\_bucket\_domain\_name](#output\_access\_logs\_bucket\_domain\_name) | Access Logs S3 bucket domain name. |
| [access\_logs\_bucket\_id](#output\_access\_logs\_bucket\_id) | Access Logs S3 bucket ID. |
| [access\_logs\_bucket\_prefix](#output\_access\_logs\_bucket\_prefix) | Access Logs S3 bucket prefix. |
| [access\_logs\_enabled](#output\_access\_logs\_enabled) | Are Access Logs enabled. |
| [arn](#output\_arn) | The ARN of the load balancer (matches `id`). |
| [arn\_suffix](#output\_arn\_suffix) | The ARN suffix for use with CloudWatch Metrics. |
| [dns\_name](#output\_dns\_name) | The DNS name of the load balancer. |
| [enabled](#output\_enabled) | Is the module enabled. |
| [id](#output\_id) | The ARN of the load balancer (matches `arn`). |
| [security\_group\_id](#output\_security\_group\_id) | ID for the default security if `security_group_enabled` is `true`. |
| [zone\_id](#output\_zone\_id) | The canonical hosted zone ID of the load balancer (to be used in a Route 53 Alias record). |
## Breaking Changes
Please consult [BREAKING\_CHANGES.md](BREAKING\_CHANGES.md) for more information about version
history and compatibility.
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for
contributing to this project.
Be mindful of our [Code of Conduct](CODE\_OF\_CONDUCT.md).
## We're hiring
Look for current openings on BambooHR https://nventive.bamboohr.com/careers/
## Stay in touch
[nventive.com](https://nventive.com/) | [Linkedin](https://www.linkedin.com/company/nventive/) | [Instagram](https://www.instagram.com/hellonventive/) | [YouTube](https://www.youtube.com/channel/UCFQyvGEKMO10hEyvCqprp5w) | [Spotify](https://open.spotify.com/show/0lsxfIb6Ttm76jB4wgutob)