From 4954b8c2eb4a109ce706020c449a49343cd723b5 Mon Sep 17 00:00:00 2001 From: bqbn Date: Mon, 23 Oct 2023 18:24:46 -0700 Subject: [PATCH] Can't use the optional funtion for non-object type attributes Error was Keyword "optional" is valid only as a modifier for object type attributes. --- google_psc_to_elastic/main.tf | 5 ++++- google_psc_to_elastic/variables.tf | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/google_psc_to_elastic/main.tf b/google_psc_to_elastic/main.tf index 07a23db4..1abd6e77 100644 --- a/google_psc_to_elastic/main.tf +++ b/google_psc_to_elastic/main.tf @@ -3,13 +3,16 @@ locals { name = "${var.name}-${var.gcp_region}-psc-elastic-endpoint" } +data "google_project" "project" { +} + data "ec_gcp_private_service_connect_endpoint" "default" { region = var.gcp_region } data "google_compute_network" "default" { name = var.network_name - project = try(var.project_id_for_network, null) + project = var.project_id_for_network != "" ? var.project_id_for_network : data.google_project.project.project_id } data "google_compute_subnetwork" "default" { diff --git a/google_psc_to_elastic/variables.tf b/google_psc_to_elastic/variables.tf index fb6b0de8..48355db4 100644 --- a/google_psc_to_elastic/variables.tf +++ b/google_psc_to_elastic/variables.tf @@ -15,7 +15,8 @@ variable "network_name" { variable "project_id_for_network" { description = "The project ID of the network" - type = optional(string) + type = string + default = "" } variable "subnetwork_name" {