From 5d26d6c39aa784a44c2bda81f2adab2a738764cd Mon Sep 17 00:00:00 2001 From: Maeghan Porter Date: Tue, 24 Nov 2020 18:53:23 -0400 Subject: [PATCH] Add health_check_path to allow the health check to use a port other than traffic-port (#63) ## what * Allows the specification of a health check port that is not the traffic-port. ## why * The health check endpoint doesn't necessarily always exist on the default traffic-port, as is my case. --- README.md | 1 + docs/terraform.md | 1 + main.tf | 1 + variables.tf | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 3b03883..619ff4b 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ Available targets: | health\_check\_interval | The duration in seconds in between health checks | `number` | `15` | no | | health\_check\_matcher | The HTTP response codes to indicate a healthy check | `string` | `"200-399"` | no | | health\_check\_path | The destination for the health check request | `string` | `"/"` | no | +| health\_check\_port | The port to use for the healthcheck | `string` | `"traffic-port"` | no | | health\_check\_timeout | The amount of time to wait in seconds before failing a health check request | `number` | `10` | no | | health\_check\_unhealthy\_threshold | The number of consecutive health check failures required before considering the target unhealthy | `number` | `2` | no | | http2\_enabled | A boolean flag to enable/disable HTTP/2 | `bool` | `true` | no | diff --git a/docs/terraform.md b/docs/terraform.md index b52fab0..67b86e7 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -39,6 +39,7 @@ | health\_check\_interval | The duration in seconds in between health checks | `number` | `15` | no | | health\_check\_matcher | The HTTP response codes to indicate a healthy check | `string` | `"200-399"` | no | | health\_check\_path | The destination for the health check request | `string` | `"/"` | no | +| health\_check\_port | The port to use for the healthcheck | `string` | `"traffic-port"` | no | | health\_check\_timeout | The amount of time to wait in seconds before failing a health check request | `number` | `10` | no | | health\_check\_unhealthy\_threshold | The number of consecutive health check failures required before considering the target unhealthy | `number` | `2` | no | | http2\_enabled | A boolean flag to enable/disable HTTP/2 | `bool` | `true` | no | diff --git a/main.tf b/main.tf index 4694bd4..5bc1245 100644 --- a/main.tf +++ b/main.tf @@ -101,6 +101,7 @@ resource "aws_lb_target_group" "default" { health_check { protocol = var.target_group_protocol path = var.health_check_path + port = var.health_check_port timeout = var.health_check_timeout healthy_threshold = var.health_check_healthy_threshold unhealthy_threshold = var.health_check_unhealthy_threshold diff --git a/variables.tf b/variables.tf index 40bcf36..1549333 100644 --- a/variables.tf +++ b/variables.tf @@ -140,6 +140,12 @@ variable "health_check_path" { description = "The destination for the health check request" } +variable "health_check_port" { + type = string + default = "traffic-port" + description = "The port to use for the healthcheck" +} + variable "health_check_timeout" { type = number default = 10