Skip to content

Commit

Permalink
Can't use the optional funtion for non-object type attributes
Browse files Browse the repository at this point in the history
Error was

Keyword "optional" is valid only as a modifier for object type attributes.
  • Loading branch information
bqbn committed Oct 24, 2023
1 parent cda7355 commit 4954b8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion google_psc_to_elastic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
3 changes: 2 additions & 1 deletion google_psc_to_elastic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 4954b8c

Please sign in to comment.