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" {
count = var.hub.create ? 1 : 0
project = var.project_id
name = var.name
description = var.description
name = var.hub.name
description = var.hub.description
}
resource "google_network_connectivity_spoke" "spoke-ra" {
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
name = var.name
linked_router_appliance_instances {

View File

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