Skip to content

Commit f65f13d

Browse files
committed
Update ncc example to use star topology
1 parent 165c316 commit f65f13d

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

examples/network_connectivity_center/main.tf

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,32 @@ module "network_connectivity_center" {
2323
ncc_hub_labels = {
2424
"module" = "ncc"
2525
}
26+
ncc_hub_preset_topology = "STAR"
27+
ncc_groups = {
28+
"center" = {
29+
name = "center"
30+
labels = {
31+
"module" = "ncc"
32+
}
33+
}
34+
"edge" = {
35+
name = "edge"
36+
auto_accept_projects = [
37+
"foo",
38+
"bar"
39+
]
40+
}
41+
}
2642
spoke_labels = {
2743
"created-by" = "terraform-google-ncc-example"
2844
}
29-
3045
vpc_spokes = {
3146
"vpc-1" = {
3247
uri = module.vpc_spoke_vpc.network_id
3348
labels = {
3449
"spoke-type" = "vpc"
3550
}
51+
group = "edge"
3652
}
3753
"producer-conn" = {
3854
uri = google_compute_network.producer_connected_network.id
@@ -49,6 +65,7 @@ module "network_connectivity_center" {
4965
"198.51.100.0/24",
5066
"10.10.0.0/16"
5167
]
68+
group = "center"
5269
}
5370
}
5471
}
@@ -59,6 +76,7 @@ module "network_connectivity_center" {
5976
uris = [for k, v in module.local_to_remote_vpn.tunnel_self_links : v]
6077
site_to_site_data_transfer = true
6178
location = var.vpn_region
79+
group = "center"
6280
}
6381
}
6482
router_appliance_spokes = {
@@ -72,6 +90,7 @@ module "network_connectivity_center" {
7290
]
7391
location = var.instance_region
7492
site_to_site_data_transfer = false
93+
group = "center"
7594
}
7695
}
7796
}

modules/network-connectivity-center/main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ resource "google_network_connectivity_hub" "hub" {
5050
resource "google_network_connectivity_group" "group" {
5151
for_each = var.ncc_groups
5252
name = each.value.name
53-
hub = google_network_connectivity_hub.hub.name
53+
hub = google_network_connectivity_hub.hub.id
5454
project = var.project_id
5555
auto_accept {
5656
auto_accept_projects = each.value.auto_accept_projects
@@ -82,6 +82,7 @@ resource "google_network_connectivity_spoke" "producer_vpc_network_spoke" {
8282
description = each.value.description
8383
hub = google_network_connectivity_hub.hub.id
8484
labels = merge(var.spoke_labels, each.value.labels)
85+
group = each.value.group
8586

8687
linked_producer_vpc_network {
8788
network = each.value.network_name
@@ -100,6 +101,7 @@ resource "google_network_connectivity_spoke" "hybrid_spoke" {
100101
description = each.value.description
101102
hub = google_network_connectivity_hub.hub.id
102103
labels = merge(var.spoke_labels, each.value.labels)
104+
group = each.value.group
103105

104106
dynamic "linked_interconnect_attachments" {
105107
for_each = each.value.type == "interconnect" ? [1] : []
@@ -128,6 +130,7 @@ resource "google_network_connectivity_spoke" "router_appliance_spoke" {
128130
description = each.value.description
129131
hub = google_network_connectivity_hub.hub.id
130132
labels = merge(var.spoke_labels, each.value.labels)
133+
group = each.value.group
131134

132135
linked_router_appliance_instances {
133136
dynamic "instances" {

modules/network-connectivity-center/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ variable "vpc_spokes" {
7878
exclude_export_ranges = optional(list(string))
7979
description = optional(string)
8080
labels = optional(map(string))
81+
group = optional(string)
8182
}))
8283
}))
8384
default = {}
@@ -104,6 +105,7 @@ variable "hybrid_spokes" {
104105
description = optional(string)
105106
labels = optional(map(string))
106107
include_import_ranges = optional(list(string), [])
108+
group = optional(string)
107109
}))
108110
default = {}
109111
}
@@ -120,6 +122,7 @@ variable "router_appliance_spokes" {
120122
description = optional(string)
121123
labels = optional(map(string))
122124
include_import_ranges = optional(list(string), [])
125+
group = optional(string)
123126
}))
124127
default = {}
125128
}

0 commit comments

Comments
 (0)