Skip to content

Commit aefabf9

Browse files
committed
Healthcheck toggle
1 parent 873b335 commit aefabf9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ resource "google_bigquery_dataset_iam_member" "dataset_bigquery_data_editor_bind
8282
# --- CE: Firewall rules
8383

8484
resource "google_compute_firewall" "ingress_health_check" {
85-
name = "${var.name}-traffic-in"
85+
count = var.healthcheck_enabled == true ? 1 : 0
86+
name = "${var.name}-traffic-in"
8687

8788
network = var.network
8889
target_tags = [var.name]
@@ -245,7 +246,7 @@ module "service" {
245246
service_account_email = google_service_account.sa.email
246247
associate_public_ip_address = var.associate_public_ip_address
247248

248-
named_port_http = "http"
249-
ingress_port = local.ingress_port
250-
health_check_path = "/"
249+
named_port_http = var.healthcheck_enabled == true ? "http" : ""
250+
ingress_port = var.healthcheck_enabled == true ? local.ingress_port : -1
251+
health_check_path = var.healthcheck_enabled == true ? "/" : ""
251252
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,9 @@ variable "skip_schemas" {
209209
type = list(string)
210210
default = []
211211
}
212+
213+
variable "healthcheck_enabled" {
214+
description = "Whether or not to enable health check probe for GCP instance group"
215+
type = bool
216+
default = true
217+
}

0 commit comments

Comments
 (0)