Update ncc-spoke-ra module to explicity request ncc hub id when referencing existing hubs (#1479)
* Updated ncc-spoke-ra module to explicity requesting ncc hub id when referencing existing hub * fix documentation * updated hub variable description * more explicit validation condition on hub variable
This commit is contained in:
parent
5da7dc0796
commit
dd37d07955
|
@ -40,7 +40,7 @@ module "spoke-ra" {
|
|||
```hcl
|
||||
module "spoke-ra-a" {
|
||||
source = "./fabric/modules/ncc-spoke-ra"
|
||||
hub = { name = "ncc-hub" }
|
||||
hub = { id = "projects/my-project/locations/global/hubs/ncc-hub" }
|
||||
name = "spoke-ra-a"
|
||||
project_id = "my-project"
|
||||
region = "europe-west1"
|
||||
|
@ -64,7 +64,7 @@ module "spoke-ra-a" {
|
|||
|
||||
module "spoke-ra-b" {
|
||||
source = "./fabric/modules/ncc-spoke-ra"
|
||||
hub = { name = "ncc-hub" }
|
||||
hub = { id = "projects/my-project/locations/global/hubs/ncc-hub" }
|
||||
name = "spoke-ra-b"
|
||||
project_id = "my-project"
|
||||
region = "europe-west3"
|
||||
|
@ -93,7 +93,7 @@ module "spoke-ra-b" {
|
|||
```hcl
|
||||
module "spoke-ra" {
|
||||
source = "./fabric/modules/ncc-spoke-ra"
|
||||
hub = { name = "ncc-hub" }
|
||||
hub = { id = "projects/my-project/locations/global/hubs/ncc-hub" }
|
||||
name = "spoke-ra"
|
||||
project_id = "my-project"
|
||||
region = "europe-west1"
|
||||
|
@ -132,13 +132,13 @@ module "spoke-ra" {
|
|||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [hub](variables.tf#L23) | The name of the NCC hub to create or use. | <code title="object({ create = optional(bool, false) description = optional(string) name = string })">object({…})</code> | ✓ | |
|
||||
| [name](variables.tf#L32) | The name of the NCC spoke. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L37) | The ID of the project where the NCC hub & spokes will be created. | <code>string</code> | ✓ | |
|
||||
| [region](variables.tf#L42) | Region where the spoke is located. | <code>string</code> | ✓ | |
|
||||
| [router_appliances](variables.tf#L47) | List of router appliances this spoke is associated with. | <code title="list(object({ internal_ip = string vm_self_link = string }))">list(object({…}))</code> | ✓ | |
|
||||
| [router_config](variables.tf#L55) | Configuration of the Cloud Router. | <code title="object({ asn = number custom_advertise = optional(object({ all_subnets = bool ip_ranges = map(string) })) ip_interface0 = string ip_interface1 = string keepalive = optional(number) peer_asn = number routes_priority = optional(number, 100) })">object({…})</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L71) | Network and subnetwork for the CR interfaces. | <code title="object({ network_name = string subnet_self_link = string })">object({…})</code> | ✓ | |
|
||||
| [hub](variables.tf#L23) | The NCC hub. You should either provide an existing hub id or a hub name if create is true. | <code title="object({ create = optional(bool, false) description = optional(string) id = optional(string) name = optional(string) })">object({…})</code> | ✓ | |
|
||||
| [name](variables.tf#L37) | The name of the NCC spoke. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L42) | The ID of the project where the NCC hub & spokes will be created. | <code>string</code> | ✓ | |
|
||||
| [region](variables.tf#L47) | Region where the spoke is located. | <code>string</code> | ✓ | |
|
||||
| [router_appliances](variables.tf#L52) | List of router appliances this spoke is associated with. | <code title="list(object({ internal_ip = string vm_self_link = string }))">list(object({…}))</code> | ✓ | |
|
||||
| [router_config](variables.tf#L60) | Configuration of the Cloud Router. | <code title="object({ asn = number custom_advertise = optional(object({ all_subnets = bool ip_ranges = map(string) })) ip_interface0 = string ip_interface1 = string keepalive = optional(number) peer_asn = number routes_priority = optional(number, 100) })">object({…})</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L76) | Network and subnetwork for the CR interfaces. | <code title="object({ network_name = string subnet_self_link = string })">object({…})</code> | ✓ | |
|
||||
| [data_transfer](variables.tf#L17) | Site-to-site data transfer feature, available only in some regions. | <code>bool</code> | | <code>false</code> |
|
||||
|
||||
## Outputs
|
||||
|
|
|
@ -35,7 +35,7 @@ resource "google_network_connectivity_hub" "hub" {
|
|||
|
||||
resource "google_network_connectivity_spoke" "spoke-ra" {
|
||||
project = var.project_id
|
||||
hub = try(google_network_connectivity_hub.hub[0].name, var.hub.name)
|
||||
hub = try(google_network_connectivity_hub.hub[0].id, var.hub.id)
|
||||
location = var.region
|
||||
name = var.name
|
||||
linked_router_appliance_instances {
|
||||
|
|
|
@ -21,12 +21,17 @@ variable "data_transfer" {
|
|||
}
|
||||
|
||||
variable "hub" {
|
||||
description = "The name of the NCC hub to create or use."
|
||||
description = "The NCC hub. You should either provide an existing hub id or a hub name if create is true."
|
||||
type = object({
|
||||
create = optional(bool, false)
|
||||
description = optional(string)
|
||||
name = string
|
||||
id = optional(string)
|
||||
name = optional(string)
|
||||
})
|
||||
validation {
|
||||
condition = var.hub.create && var.hub.name != null || var.hub.create == false && var.hub.id != null
|
||||
error_message = "Name is required for configuring new ncc hub while referencing existing hub requires id."
|
||||
}
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
|
|
Loading…
Reference in New Issue