diff --git a/examples/minimal/main.tf b/examples/minimal/main.tf index 238894b..d5a54c1 100644 --- a/examples/minimal/main.tf +++ b/examples/minimal/main.tf @@ -46,6 +46,7 @@ locals { request = "" request_path = "/" host = "1.2.3.4" + enable_log = false } } diff --git a/examples/simple/locals.tf b/examples/simple/locals.tf index 07287e3..43b1943 100644 --- a/examples/simple/locals.tf +++ b/examples/simple/locals.tf @@ -32,5 +32,6 @@ locals { request = "" request_path = "/" host = "1.2.3.4" + enable_log = false } } diff --git a/examples/simple/main.tf b/examples/simple/main.tf index cba3c1c..dc45939 100644 --- a/examples/simple/main.tf +++ b/examples/simple/main.tf @@ -18,6 +18,10 @@ provider "google" { version = "~> 3.62.0" } +provider "google-beta" { + version = "~> 3.62.0" +} + module "gce-lb-fr" { source = "GoogleCloudPlatform/lb/google" version = "~> 2.3" diff --git a/main.tf b/main.tf index 5f3a219..4adb824 100644 --- a/main.tf +++ b/main.tf @@ -62,9 +62,10 @@ resource "google_compute_region_backend_service" "default" { } resource "google_compute_health_check" "tcp" { - count = var.health_check["type"] == "tcp" ? 1 : 0 - project = var.project - name = "${var.name}-hc-tcp" + provider = google-beta + count = var.health_check["type"] == "tcp" ? 1 : 0 + project = var.project + name = "${var.name}-hc-tcp" timeout_sec = var.health_check["timeout_sec"] check_interval_sec = var.health_check["check_interval_sec"] @@ -78,12 +79,20 @@ resource "google_compute_health_check" "tcp" { port_name = var.health_check["port_name"] proxy_header = var.health_check["proxy_header"] } + + dynamic "log_config" { + for_each = var.health_check["enable_log"] ? [true] : [] + content { + enable = true + } + } } resource "google_compute_health_check" "http" { - count = var.health_check["type"] == "http" ? 1 : 0 - project = var.project - name = "${var.name}-hc-http" + provider = google-beta + count = var.health_check["type"] == "http" ? 1 : 0 + project = var.project + name = "${var.name}-hc-http" timeout_sec = var.health_check["timeout_sec"] check_interval_sec = var.health_check["check_interval_sec"] @@ -98,6 +107,13 @@ resource "google_compute_health_check" "http" { port_name = var.health_check["port_name"] proxy_header = var.health_check["proxy_header"] } + + dynamic "log_config" { + for_each = var.health_check["enable_log"] ? [true] : [] + content { + enable = true + } + } } resource "google_compute_firewall" "default-ilb-fw" { @@ -132,4 +148,3 @@ resource "google_compute_firewall" "default-hc" { target_tags = var.target_tags target_service_accounts = var.target_service_accounts } - diff --git a/variables.tf b/variables.tf index b4ff3fd..9721e75 100644 --- a/variables.tf +++ b/variables.tf @@ -85,6 +85,7 @@ variable "health_check" { request = string request_path = string host = string + enable_log = bool }) }