|
1 | 1 | <!-- BEGIN_TF_DOCS --> |
2 | 2 | # alb |
3 | 3 |
|
| 4 | +This sub-module creates: |
| 5 | + |
| 6 | +1. Application Load Balancer in the given subnets |
| 7 | +2. Target Groups with Health Check configuration |
| 8 | +3. Listeners with Default Action configuration, and |
| 9 | +4. Listener Rules with Actions with `forward` and `authenticate-oidc` types, and Conditions involving `host_header`, `path_pattern`, and `http_request_method`. |
| 10 | + |
| 11 | +## Presets |
| 12 | + |
| 13 | +### Load Balancer |
| 14 | + |
| 15 | +- The `internal` is set to `false` as the default option (i.e., an Internet-facing ALB), and can be overridden to be internal if required. |
| 16 | +- The `preserve_host_header` is set to `true` as the default option (i.e., the `HOST` header is not overridden by the ALB), and can be overridden to allow the ALB to override the header if required. |
| 17 | +- The `enable_deletion_protection` is set to `false` as the recommended option (i.e., the ALB can be destroyed using the API), and can be overridden to enable the deletion protection if required. |
| 18 | + |
| 19 | +### Listener |
| 20 | + |
| 21 | +- The `protocol` is set to `HTTP` as the default option, and can be overridden to use `HTTPS` if required. |
| 22 | +- The `ssl_policy` is set to `ELBSecurityPolicy-TLS13-1-2-2021-06` as the recommended SSL policy ([read more](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html#describe-ssl-policies)), and can be overridden to use a different SSL policy if required. |
| 23 | + |
| 24 | +## Notes |
| 25 | + |
| 26 | +- For configuration that requires ARNs to other Target Groups/Listeners, the name of the Target Group/Listener can be specified as the value of the attribute, so that the sub-module implicitly references the corresponding Target Group/Listener for the ARN. |
| 27 | + |
| 28 | + ```hcl |
| 29 | + module "alb" { |
| 30 | + . . . |
| 31 | +
|
| 32 | + target_groups = { |
| 33 | + # Define the Target Group with a key |
| 34 | + nginx = { |
| 35 | + . . . |
| 36 | + } |
| 37 | + } |
| 38 | +
|
| 39 | + listeners = { |
| 40 | + . . . |
| 41 | + default_action = [ |
| 42 | + { |
| 43 | + . . . |
| 44 | +
|
| 45 | + # Reference the target group using the key |
| 46 | + target_group = "nginx" |
| 47 | + } |
| 48 | + ] |
| 49 | + } |
| 50 | + } |
| 51 | + ``` |
| 52 | + |
| 53 | +- Listener Rule Actions currently support the `forward` and `authenticate-oidc` types only, and will be expanded to cover other types in future iteratively. Similarly, the Listener Rule Conditions currently support the `host_header`, `path_pattern` and `http_request_method` configurations only. |
| 54 | + |
4 | 55 | ## Requirements |
5 | 56 |
|
6 | 57 | | Name | Version | |
@@ -34,8 +85,8 @@ No modules. |
34 | 85 | | <a name="input_internal"></a> [internal](#input\_internal) | (Optional) If true, the LB will be internal. | `bool` | `false` | no | |
35 | 86 | | <a name="input_listener_rules"></a> [listener\_rules](#input\_listener\_rules) | Listener rules to associate with the the ALB Listeners. | <pre>map(object({<br> listener = string<br> priority = optional(number)<br> action = list(object({<br> type = string<br> authenticate_oidc = optional(object({<br> authorization_endpoint = string<br> client_id = string<br> client_secret = string<br> issuer = string<br> on_unauthenticated_request = optional(string)<br> scope = optional(string)<br> session_cookie_name = optional(string)<br> token_endpoint = string<br> user_info_endpoint = string<br> }))<br> target_group = optional(string)<br> }))<br> condition = set(object({<br> host_header = optional(object({<br> values = set(string)<br> }))<br> path_pattern = optional(object({<br> values = set(string)<br> }))<br> http_request_method = optional(object({<br> values = set(string)<br> }))<br> }))<br> tags = optional(map(string), {})<br> }))</pre> | `{}` | no | |
36 | 87 | | <a name="input_listeners"></a> [listeners](#input\_listeners) | Listeners to forward ALB ingress to desired Target Groups. | <pre>map(object({<br> default_action = list(object({<br> type = string<br> target_group = string<br> fixed_response = optional(any, null)<br> forward = optional(any, null)<br> order = optional(number)<br> redirect = optional(any, null)<br> }))<br> certificate_arn = optional(string)<br> port = optional(number)<br> protocol = optional(string, "HTTP")<br> ssl_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")<br> tags = optional(map(string), {})<br> }))</pre> | n/a | yes | |
37 | | -| <a name="input_name"></a> [name](#input\_name) | (Optional) Name of the LB. | `string` | `""` | no | |
38 | | -| <a name="input_preserve_host_header"></a> [preserve\_host\_header](#input\_preserve\_host\_header) | (Optional) Whether the Application Load Balancer should preserve the Host header in the HTTP request and send it to the target without any change. | `bool` | `false` | no | |
| 88 | +| <a name="input_name"></a> [name](#input\_name) | (Optional) Name of the LB. | `string` | `null` | no | |
| 89 | +| <a name="input_preserve_host_header"></a> [preserve\_host\_header](#input\_preserve\_host\_header) | (Optional) Whether the Application Load Balancer should preserve the Host header in the HTTP request and send it to the target without any change. | `bool` | `true` | no | |
39 | 90 | | <a name="input_security_groups_ids"></a> [security\_groups\_ids](#input\_security\_groups\_ids) | (Optional) List of security group IDs to assign to the LB. | `list(string)` | `[]` | no | |
40 | 91 | | <a name="input_subnets_ids"></a> [subnets\_ids](#input\_subnets\_ids) | (Optional) List of subnet IDs to attach to the LB. | `list(string)` | n/a | yes | |
41 | 92 | | <a name="input_tags"></a> [tags](#input\_tags) | (Optional) Map of tags to assign to the resource. | `map(string)` | `{}` | no | |
|
0 commit comments