Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

modules/lb_internal issue for multi-region #220

Closed
horiagunica opened this issue Aug 31, 2023 · 0 comments · Fixed by #221
Closed

modules/lb_internal issue for multi-region #220

horiagunica opened this issue Aug 31, 2023 · 0 comments · Fixed by #221
Labels
enhancement New feature or request

Comments

@horiagunica
Copy link
Contributor

Is your feature request related to a problem?

When the google provider does not have a default region configured (which is actually happening in examples/vpc_peering_common_with_network_tags example) the data source used within the lb_internal module returns a null value and interpolation fails:

data "google_client_config" "this" {}

resource "google_compute_health_check" "this" {
  name    = "${var.name}-${data.google_client_config.this.region}-check-tcp${var.health_check_port}"
  project = var.project

  tcp_health_check {
    port = var.health_check_port
  }
}

Error :

│ Error: Invalid template interpolation value
│
│   on ../../modules/lb_internal/main.tf line 4, in resource "google_compute_health_check" "this":
│    4:   name    = "${var.name}-${data.google_client_config.this.region}-check-tcp${var.health_check_port}"
│     ├────────────────
│     │ data.google_client_config.this.region is null
│
│ The expression result is null. Cannot include a null value in a string template.
╵
╷
│ Error: Invalid template interpolation value
│
│   on ../../modules/lb_internal/main.tf line 4, in resource "google_compute_health_check" "this":
│    4:   name    = "${var.name}-${data.google_client_config.this.region}-check-tcp${var.health_check_port}"
│     ├────────────────
│     │ data.google_client_config.this.region is null
│
│ The expression result is null. Cannot include a null value in a string template.
╵

Describe the solution you'd like

var.region is already used within the module so there is no use for the data source.

Thus - get rid of the data source and use var.region variable instead:

resource "google_compute_health_check" "this" {
  name    = "${var.name}-${var.region}-check-tcp${var.health_check_port}"
  project = var.project

  tcp_health_check {
    port = var.health_check_port
  }
}

Describe alternatives you've considered.

No response

Additional context

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
1 participant