Skip to content

Commit

Permalink
Merge pull request #22 from terraform-google-modules/aaron-lane-defau…
Browse files Browse the repository at this point in the history
…lt-health-check-port

Default health check port to service port
  • Loading branch information
Aaron Lane authored Nov 26, 2019
2 parents 217f99e + a2c94d5 commit fec1ef9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* limitations under the License.
*/

locals {
health_check_port = var.health_check["port"]
}

resource "google_compute_forwarding_rule" "default" {
project = var.project
name = var.name
Expand Down Expand Up @@ -44,7 +48,7 @@ resource "google_compute_http_health_check" "default" {
timeout_sec = var.health_check["timeout_sec"]
unhealthy_threshold = var.health_check["unhealthy_threshold"]

port = var.health_check["port"]
port = local.health_check_port == null ? var.service_port : local.health_check_port
request_path = var.health_check["request_path"]
host = var.health_check["host"]
}
Expand All @@ -71,7 +75,7 @@ resource "google_compute_firewall" "default-hc-fw" {

allow {
protocol = "tcp"
ports = [var.health_check["port"] == null ? 80 : var.health_check["port"]]
ports = [local.health_check_port == null ? 80 : local.health_check_port]
}

source_ranges = ["35.191.0.0/16", "209.85.152.0/22", "209.85.204.0/22"]
Expand Down

0 comments on commit fec1ef9

Please sign in to comment.