Make creation of the hub optional

This commit is contained in:
Julio Diez 2023-03-08 16:41:02 +01:00
parent 1b4ba11dcd
commit 34c6a6aee1
2 changed files with 12 additions and 8 deletions

View File

@ -25,14 +25,15 @@ locals {
} }
resource "google_network_connectivity_hub" "hub" { resource "google_network_connectivity_hub" "hub" {
count = var.hub.create ? 1 : 0
project = var.project_id project = var.project_id
name = var.name name = var.hub.name
description = var.description description = var.hub.description
} }
resource "google_network_connectivity_spoke" "spoke-ra" { resource "google_network_connectivity_spoke" "spoke-ra" {
project = var.project_id project = var.project_id
hub = google_network_connectivity_hub.hub.id hub = try(google_network_connectivity_hub.hub[0].name, var.hub.name)
location = var.region location = var.region
name = var.name name = var.name
linked_router_appliance_instances { linked_router_appliance_instances {

View File

@ -34,10 +34,13 @@ variable "data_transfer" {
default = false default = false
} }
variable "description" { variable "hub" {
description = "An optional description of the NCC hub." description = "The name of the NCC hub to create or use."
type = string type = object({
default = "Terraform-managed." create = optional(bool, false)
name = string
description = optional(string)
})
} }
variable "ip_intf1" { variable "ip_intf1" {
@ -59,7 +62,7 @@ variable "keepalive" {
} }
variable "name" { variable "name" {
description = "The name of the NCC hub being created." description = "The name of the NCC spoke."
type = string type = string
} }