Skip to content

Commit 4bcfd20

Browse files
authored
Add support for health check port and protocol version (#63)
1 parent dc7c838 commit 4bcfd20

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ In order to run all checks at any point run the following command:
4343

4444
| Name | Version |
4545
|------|---------|
46-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.48.0 |
47-
| <a name="provider_random"></a> [random](#provider\_random) | 3.4.3 |
46+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.92.0 |
47+
| <a name="provider_random"></a> [random](#provider\_random) | 3.7.1 |
4848

4949
## Modules
5050

5151
| Name | Source | Version |
5252
|------|--------|---------|
53-
| <a name="module_lb_logs_s3"></a> [lb\_logs\_s3](#module\_lb\_logs\_s3) | cn-terraform/logs-s3-bucket/aws | 1.0.5 |
53+
| <a name="module_lb_logs_s3"></a> [lb\_logs\_s3](#module\_lb\_logs\_s3) | cn-terraform/logs-s3-bucket/aws | 1.0.6 |
5454

5555
## Resources
5656

@@ -84,12 +84,12 @@ In order to run all checks at any point run the following command:
8484
| <a name="input_enable_http2"></a> [enable\_http2](#input\_enable\_http2) | (Optional) Indicates whether HTTP/2 is enabled in the load balancer. Defaults to true. | `bool` | `true` | no |
8585
| <a name="input_enable_s3_bucket_server_side_encryption"></a> [enable\_s3\_bucket\_server\_side\_encryption](#input\_enable\_s3\_bucket\_server\_side\_encryption) | (Optional) If true, server side encryption will be applied. Ignored if log\_bucket\_id is provided. | `bool` | `true` | no |
8686
| <a name="input_enable_s3_logs"></a> [enable\_s3\_logs](#input\_enable\_s3\_logs) | (Optional) If true, all LoadBalancer logs will be sent to S3. If true, and log\_bucket\_id is *not* provided, this module will create the bucket with other provided s3 bucket configuration options | `bool` | `true` | no |
87-
| <a name="input_http_ingress_cidr_blocks"></a> [http\_ingress\_cidr\_blocks](#input\_http\_ingress\_cidr\_blocks) | List of CIDR blocks to allowed to access the Load Balancer through HTTP | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
87+
| <a name="input_http_ingress_cidr_blocks"></a> [http\_ingress\_cidr\_blocks](#input\_http\_ingress\_cidr\_blocks) | List of CIDR blocks to allowed to access the Load Balancer through HTTP | `list(string)` | <pre>[<br/> "0.0.0.0/0"<br/>]</pre> | no |
8888
| <a name="input_http_ingress_prefix_list_ids"></a> [http\_ingress\_prefix\_list\_ids](#input\_http\_ingress\_prefix\_list\_ids) | List of prefix list IDs blocks to allowed to access the Load Balancer through HTTP | `list(string)` | `[]` | no |
89-
| <a name="input_http_ports"></a> [http\_ports](#input\_http\_ports) | Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener\_port and the target\_group\_port. For `redirect` type, include listener port, host, path, port, protocol, query and status\_code. For `fixed-response`, include listener\_port, content\_type, message\_body and status\_code | `map(any)` | <pre>{<br> "default_http": {<br> "listener_port": 80,<br> "target_group_port": 80,<br> "type": "forward"<br> }<br>}</pre> | no |
90-
| <a name="input_https_ingress_cidr_blocks"></a> [https\_ingress\_cidr\_blocks](#input\_https\_ingress\_cidr\_blocks) | List of CIDR blocks to allowed to access the Load Balancer through HTTPS | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
89+
| <a name="input_http_ports"></a> [http\_ports](#input\_http\_ports) | Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener\_port and the target\_group\_port. For `redirect` type, include listener port, host, path, port, protocol, query and status\_code. For `fixed-response`, include listener\_port, content\_type, message\_body and status\_code | `map(any)` | <pre>{<br/> "default": {<br/> "listener_port": 80,<br/> "target_group_port": 80,<br/> "target_group_protocol": "HTTP",<br/> "target_group_protocol_version": "HTTP1",<br/> "type": "forward"<br/> }<br/>}</pre> | no |
90+
| <a name="input_https_ingress_cidr_blocks"></a> [https\_ingress\_cidr\_blocks](#input\_https\_ingress\_cidr\_blocks) | List of CIDR blocks to allowed to access the Load Balancer through HTTPS | `list(string)` | <pre>[<br/> "0.0.0.0/0"<br/>]</pre> | no |
9191
| <a name="input_https_ingress_prefix_list_ids"></a> [https\_ingress\_prefix\_list\_ids](#input\_https\_ingress\_prefix\_list\_ids) | List of prefix list IDs blocks to allowed to access the Load Balancer through HTTPS | `list(string)` | `[]` | no |
92-
| <a name="input_https_ports"></a> [https\_ports](#input\_https\_ports) | Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener\_port and the target\_group\_port. For `redirect` type, include listener port, host, path, port, protocol, query and status\_code. For `fixed-response`, include listener\_port, content\_type, message\_body and status\_code | `map(any)` | <pre>{<br> "default_http": {<br> "listener_port": 443,<br> "target_group_port": 443,<br> "type": "forward"<br> }<br>}</pre> | no |
92+
| <a name="input_https_ports"></a> [https\_ports](#input\_https\_ports) | Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener\_port and the target\_group\_port. For `redirect` type, include listener port, host, path, port, protocol, query and status\_code. For `fixed-response`, include listener\_port, content\_type, message\_body and status\_code | `map(any)` | <pre>{<br/> "default": {<br/> "listener_port": 443,<br/> "target_group_port": 443,<br/> "target_group_protocol": "HTTP",<br/> "target_group_protocol_version": "HTTP1",<br/> "type": "forward"<br/> }<br/>}</pre> | no |
9393
| <a name="input_idle_timeout"></a> [idle\_timeout](#input\_idle\_timeout) | (Optional) The time in seconds that the connection is allowed to be idle. Default: 60. | `number` | `60` | no |
9494
| <a name="input_internal"></a> [internal](#input\_internal) | (Optional) If true, the LB will be internal. | `bool` | `false` | no |
9595
| <a name="input_ip_address_type"></a> [ip\_address\_type](#input\_ip\_address\_type) | (Optional) The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4 and dualstack. Defaults to ipv4 | `string` | `"ipv4"` | no |
@@ -103,13 +103,14 @@ In order to run all checks at any point run the following command:
103103
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | (Optional) A list of security group IDs to assign to the LB. | `list(string)` | `[]` | no |
104104
| <a name="input_slow_start"></a> [slow\_start](#input\_slow\_start) | (Optional) The amount time for targets to warm up before the load balancer sends them a full share of requests. The range is 30-900 seconds or 0 to disable. The default value is 0 seconds. | `number` | `0` | no |
105105
| <a name="input_ssl_policy"></a> [ssl\_policy](#input\_ssl\_policy) | (Optional) The name of the SSL Policy for the listener. . Required if var.https\_ports is set. | `string` | `null` | no |
106-
| <a name="input_stickiness"></a> [stickiness](#input\_stickiness) | (Optional) A Stickiness block. Provide three fields. type, the type of sticky sessions. The only current possible value is lb\_cookie. cookie\_duration, 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). The default value is 1 day (86400 seconds). enabled, boolean to enable / disable stickiness. Default is true. | <pre>object({<br> type = string<br> cookie_duration = string<br> enabled = bool<br> })</pre> | <pre>{<br> "cookie_duration": 86400,<br> "enabled": true,<br> "type": "lb_cookie"<br>}</pre> | no |
106+
| <a name="input_stickiness"></a> [stickiness](#input\_stickiness) | (Optional) A Stickiness block. Provide three fields. type, the type of sticky sessions. The only current possible value is lb\_cookie. cookie\_duration, 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). The default value is 1 day (86400 seconds). enabled, boolean to enable / disable stickiness. Default is true. | <pre>object({<br/> type = string<br/> cookie_duration = string<br/> enabled = bool<br/> })</pre> | <pre>{<br/> "cookie_duration": 86400,<br/> "enabled": true,<br/> "type": "lb_cookie"<br/>}</pre> | no |
107107
| <a name="input_tags"></a> [tags](#input\_tags) | Resource tags | `map(string)` | `{}` | no |
108108
| <a name="input_target_group_health_check_enabled"></a> [target\_group\_health\_check\_enabled](#input\_target\_group\_health\_check\_enabled) | (Optional) Indicates whether health checks are enabled. Defaults to true. | `bool` | `true` | no |
109109
| <a name="input_target_group_health_check_healthy_threshold"></a> [target\_group\_health\_check\_healthy\_threshold](#input\_target\_group\_health\_check\_healthy\_threshold) | (Optional) The number of consecutive health checks successes required before considering an unhealthy target healthy. Defaults to 3. | `number` | `3` | no |
110110
| <a name="input_target_group_health_check_interval"></a> [target\_group\_health\_check\_interval](#input\_target\_group\_health\_check\_interval) | (Optional) The approximate amount of time, in seconds, between health checks of an individual target. Minimum value 5 seconds, Maximum value 300 seconds. Default 30 seconds. | `number` | `30` | no |
111111
| <a name="input_target_group_health_check_matcher"></a> [target\_group\_health\_check\_matcher](#input\_target\_group\_health\_check\_matcher) | The HTTP codes to use when checking for a successful response from a target. You can specify multiple values (for example, "200,202") or a range of values (for example, "200-299"). Default is 200. | `string` | `"200"` | no |
112112
| <a name="input_target_group_health_check_path"></a> [target\_group\_health\_check\_path](#input\_target\_group\_health\_check\_path) | The destination for the health check request. | `string` | `"/"` | no |
113+
| <a name="input_target_group_health_check_port"></a> [target\_group\_health\_check\_port](#input\_target\_group\_health\_check\_port) | (Optional) The port to use to connect with the target. Valid values are either ports 1-65536, or traffic-port. Defaults to traffic-port. | `string` | `"traffic-port"` | no |
113114
| <a name="input_target_group_health_check_timeout"></a> [target\_group\_health\_check\_timeout](#input\_target\_group\_health\_check\_timeout) | (Optional) The amount of time, in seconds, during which no response means a failed health check. The range is 2 to 120 seconds, and the default is 5 seconds. | `number` | `5` | no |
114115
| <a name="input_target_group_health_check_unhealthy_threshold"></a> [target\_group\_health\_check\_unhealthy\_threshold](#input\_target\_group\_health\_check\_unhealthy\_threshold) | (Optional) The number of consecutive health check failures required before considering the target unhealthy. Defaults to 3. | `number` | `3` | no |
115116
| <a name="input_use_random_name_for_lb"></a> [use\_random\_name\_for\_lb](#input\_use\_random\_name\_for\_lb) | If true the LB name will be a random string | `bool` | `false` | no |

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ resource "aws_lb_target_group" "lb_http_tgs" {
123123
name = "${var.name_prefix}-${each.key}-http-${each.value.target_group_port}"
124124
port = each.value.target_group_port
125125
protocol = lookup(each.value, "target_group_protocol", "HTTP")
126+
protocol_version = lookup(each.value, "target_group_protocol_version", "HTTP1")
126127
vpc_id = var.vpc_id
127128
deregistration_delay = var.deregistration_delay
128129
slow_start = var.slow_start
@@ -139,6 +140,7 @@ resource "aws_lb_target_group" "lb_http_tgs" {
139140
enabled = var.target_group_health_check_enabled
140141
interval = var.target_group_health_check_interval
141142
path = var.target_group_health_check_path
143+
port = var.target_group_health_check_port
142144
protocol = lookup(each.value, "target_group_protocol", "HTTP")
143145
timeout = var.target_group_health_check_timeout
144146
healthy_threshold = var.target_group_health_check_healthy_threshold
@@ -166,6 +168,7 @@ resource "aws_lb_target_group" "lb_https_tgs" {
166168
name = "${var.name_prefix}-${each.key}-https-${each.value.target_group_port}"
167169
port = each.value.target_group_port
168170
protocol = lookup(each.value, "target_group_protocol", "HTTP")
171+
protocol_version = lookup(each.value, "target_group_protocol_version", "HTTP1")
169172
vpc_id = var.vpc_id
170173
deregistration_delay = var.deregistration_delay
171174
slow_start = var.slow_start

variables.tf

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ variable "http_ports" {
144144
type = map(any)
145145
default = {
146146
default = {
147-
type = "forward"
148-
listener_port = 80
149-
target_group_port = 80
147+
type = "forward"
148+
listener_port = 80
149+
target_group_port = 80
150+
target_group_protocol = "HTTP"
151+
# HTTP1, HTTP2 or GRPC
152+
target_group_protocol_version = "HTTP1"
150153
}
151154
}
152155
}
@@ -156,9 +159,12 @@ variable "https_ports" {
156159
type = map(any)
157160
default = {
158161
default = {
159-
type = "forward"
160-
listener_port = 443
161-
target_group_port = 443
162+
type = "forward"
163+
listener_port = 443
164+
target_group_port = 443
165+
target_group_protocol = "HTTP"
166+
# HTTP1, HTTP2 or GRPC
167+
target_group_protocol_version = "HTTP1"
162168
}
163169
}
164170
}
@@ -292,6 +298,12 @@ variable "target_group_health_check_path" {
292298
default = "/"
293299
}
294300

301+
variable "target_group_health_check_port" {
302+
description = "(Optional) The port to use to connect with the target. Valid values are either ports 1-65536, or traffic-port. Defaults to traffic-port."
303+
type = string
304+
default = "traffic-port"
305+
}
306+
295307
variable "target_group_health_check_timeout" {
296308
description = "(Optional) The amount of time, in seconds, during which no response means a failed health check. The range is 2 to 120 seconds, and the default is 5 seconds."
297309
type = number

0 commit comments

Comments
 (0)