Skip to content

Commit 165c316

Browse files
committed
add star topology support for ncc hub and groups
1 parent 26624fe commit 165c316

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

modules/network-connectivity-center/main.tf

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,31 @@ locals {
3131
for k, v in google_network_connectivity_spoke.producer_vpc_network_spoke :
3232
k => v
3333
}
34+
groups = {
35+
for k, v in google_network_connectivity_group.group :
36+
k => v
37+
}
3438
}
3539

3640
resource "google_network_connectivity_hub" "hub" {
37-
name = var.ncc_hub_name
38-
project = var.project_id
39-
description = var.ncc_hub_description
40-
export_psc = var.export_psc
41-
labels = var.ncc_hub_labels
41+
name = var.ncc_hub_name
42+
project = var.project_id
43+
description = var.ncc_hub_description
44+
export_psc = var.export_psc
45+
labels = var.ncc_hub_labels
46+
policy_mode = var.ncc_hub_policy_mode
47+
preset_topology = var.ncc_hub_policy_mode == "PRESET" ? var.ncc_hub_preset_topology : (var.ncc_hub_policy_mode == "CUSTOM" ? "PRESET_TOPOLOGY_UNSPECIFIED" : "MESH")
4248
}
4349

50+
resource "google_network_connectivity_group" "group" {
51+
for_each = var.ncc_groups
52+
name = each.value.name
53+
hub = google_network_connectivity_hub.hub.name
54+
project = var.project_id
55+
auto_accept {
56+
auto_accept_projects = each.value.auto_accept_projects
57+
}
58+
}
4459

4560
resource "google_network_connectivity_spoke" "vpc_spoke" {
4661
for_each = var.vpc_spokes
@@ -50,6 +65,7 @@ resource "google_network_connectivity_spoke" "vpc_spoke" {
5065
description = each.value.description
5166
hub = google_network_connectivity_hub.hub.id
5267
labels = merge(var.spoke_labels, each.value.labels)
68+
group = each.value.group
5369

5470
linked_vpc_network {
5571
uri = each.value.uri

modules/network-connectivity-center/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ output "spokes" {
6060
},
6161
])
6262
}
63+
64+
output "groups" {
65+
value = local.groups
66+
}

modules/network-connectivity-center/variables.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ variable "ncc_hub_labels" {
3535
default = {}
3636
}
3737

38+
variable "ncc_hub_preset_topology" {
39+
type = string
40+
default = ""
41+
}
42+
43+
variable "ncc_hub_policy_mode" {
44+
type = string
45+
default = "PRESET"
46+
}
47+
48+
variable "ncc_groups" {
49+
type = map(object({
50+
name = string
51+
labels = optional(map(string))
52+
description = optional(string)
53+
auto_accept_projects = optional(list(string), [])
54+
}))
55+
default = {}
56+
}
57+
3858
variable "export_psc" {
3959
description = "Whether Private Service Connect transitivity is enabled for the hub"
4060
type = bool
@@ -49,6 +69,7 @@ variable "vpc_spokes" {
4969
include_export_ranges = optional(set(string), [])
5070
description = optional(string)
5171
labels = optional(map(string))
72+
group = optional(string)
5273

5374
link_producer_vpc_network = optional(object({
5475
network_name = string

0 commit comments

Comments
 (0)