Skip to content

Commit 2f7ef6e

Browse files
committed
Revert ncc example, add star module invocation
add integration test for ncc star groups add upgrading docs bump ncc module provider version
1 parent 26864eb commit 2f7ef6e

File tree

10 files changed

+93
-36
lines changed

10 files changed

+93
-36
lines changed

docs/upgrading_to_v13.0.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Upgrading to v13.0.0
2+
3+
The v13.0 release contains backwards-incompatible changes.
4+
5+
This update requires upgrading:
6+
- minimum provider version of `hashicorp/google` to `6.9` for network-connectivity-center sub-module.

examples/network_connectivity_center/main.tf

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,19 @@
1616

1717
module "network_connectivity_center" {
1818
source = "terraform-google-modules/network/google//modules/network-connectivity-center"
19-
version = "~> 12.0"
19+
version = "~> 13.0"
2020

2121
project_id = var.project_id
2222
ncc_hub_name = var.ncc_hub_name
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-
}
42-
spoke_labels = {
43-
"created-by" = "terraform-google-ncc-example"
44-
}
4526
vpc_spokes = {
4627
"vpc-1" = {
4728
uri = module.vpc_spoke_vpc.network_id
4829
labels = {
4930
"spoke-type" = "vpc"
5031
}
51-
group = "edge"
5232
}
5333
"producer-conn" = {
5434
uri = google_compute_network.producer_connected_network.id
@@ -65,7 +45,6 @@ module "network_connectivity_center" {
6545
"198.51.100.0/24",
6646
"10.10.0.0/16"
6747
]
68-
group = "center"
6948
}
7049
}
7150
}
@@ -76,7 +55,6 @@ module "network_connectivity_center" {
7655
uris = [for k, v in module.local_to_remote_vpn.tunnel_self_links : v]
7756
site_to_site_data_transfer = true
7857
location = var.vpn_region
79-
group = "center"
8058
}
8159
}
8260
router_appliance_spokes = {
@@ -90,11 +68,40 @@ module "network_connectivity_center" {
9068
]
9169
location = var.instance_region
9270
site_to_site_data_transfer = false
93-
group = "center"
9471
}
9572
}
9673
}
9774

75+
module "network_connectivity_center_star" {
76+
source = "terraform-google-modules/network/google//modules/network-connectivity-center"
77+
version = "~> 13.0"
78+
79+
project_id = var.project_id
80+
ncc_hub_name = "${var.ncc_hub_name}_star"
81+
ncc_hub_labels = {
82+
"module" = "ncc"
83+
}
84+
ncc_hub_preset_topology = "STAR"
85+
ncc_groups = {
86+
"center" = {
87+
name = "center"
88+
labels = {
89+
"module" = "ncc"
90+
}
91+
}
92+
"edge" = {
93+
name = "edge"
94+
auto_accept_projects = [
95+
"foo",
96+
"bar"
97+
]
98+
}
99+
}
100+
spoke_labels = {
101+
"created-by" = "terraform-google-ncc-example"
102+
}
103+
}
104+
98105
################################
99106
# VPC Spoke #
100107
################################

examples/network_connectivity_center/outputs.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ output "vpc_spokes" {
2929
value = module.network_connectivity_center.vpc_spokes
3030
}
3131

32-
3332
output "hybrid_spokes" {
3433
description = "All hybrid spoke objects"
3534
value = module.network_connectivity_center.hybrid_spokes
@@ -44,3 +43,13 @@ output "spokes" {
4443
description = "All spoke objects prefixed with the type of spoke (vpc, hybrid, appliance)"
4544
value = module.network_connectivity_center.spokes
4645
}
46+
47+
output "ncc_hub_name_star" {
48+
description = "Name of the NCC Hub (required for testing)"
49+
value = element(reverse(split("/", module.network_connectivity_center_star.ncc_hub.name)), 0)
50+
}
51+
52+
output "groups" {
53+
description = "All spoke objects prefixed with the type of spoke (vpc, hybrid, appliance)"
54+
value = module.network_connectivity_center_star.groups
55+
}

examples/network_connectivity_center/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ terraform {
2020
required_providers {
2121
google = {
2222
source = "hashicorp/google"
23-
version = ">= 6.49"
23+
version = ">= 6.9"
2424

2525
}
2626
}

modules/network-connectivity-center/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,23 @@ An extensive example that also contains the creation and attachment of multiple
2323
| Name | Description | Type | Default | Required |
2424
|------|-------------|------|---------|:--------:|
2525
| export\_psc | Whether Private Service Connect transitivity is enabled for the hub | `bool` | `false` | no |
26-
| hybrid\_spokes | VLAN attachments and VPN Tunnels that are associated with the spoke. Type must be one of `interconnect` and `vpn`. | <pre>map(object({<br> location = string<br> uris = set(string)<br> site_to_site_data_transfer = optional(bool, false)<br> type = string<br> description = optional(string)<br> labels = optional(map(string))<br> include_import_ranges = optional(list(string), [])<br> }))</pre> | `{}` | no |
26+
| hybrid\_spokes | VLAN attachments and VPN Tunnels that are associated with the spoke. Type must be one of `interconnect` and `vpn`. | <pre>map(object({<br> location = string<br> uris = set(string)<br> site_to_site_data_transfer = optional(bool, false)<br> type = string<br> description = optional(string)<br> labels = optional(map(string))<br> include_import_ranges = optional(list(string), [])<br> group = optional(string)<br> }))</pre> | `{}` | no |
27+
| ncc\_groups | Groups for Hubs using the star topolgy | <pre>map(object({<br> name = string<br> labels = optional(map(string))<br> description = optional(string)<br> auto_accept_projects = optional(list(string), [])<br> }))</pre> | `{}` | no |
2728
| ncc\_hub\_description | The description of the NCC Hub | `string` | `null` | no |
2829
| ncc\_hub\_labels | These labels will be added the NCC hub | `map(string)` | `{}` | no |
2930
| ncc\_hub\_name | The Name of the NCC Hub | `string` | n/a | yes |
31+
| ncc\_hub\_policy\_mode | The policy mode of the hub | `string` | `"PRESET"` | no |
32+
| ncc\_hub\_preset\_topology | The topology implemented in the hub | `string` | `null` | no |
3033
| project\_id | Project ID of the project that holds the network. | `string` | n/a | yes |
31-
| router\_appliance\_spokes | Router appliance instances that are associated with the spoke. | <pre>map(object({<br> instances = set(object({<br> virtual_machine = string<br> ip_address = string<br> }))<br> location = string<br> site_to_site_data_transfer = optional(bool, false)<br> description = optional(string)<br> labels = optional(map(string))<br> include_import_ranges = optional(list(string), [])<br> }))</pre> | `{}` | no |
34+
| router\_appliance\_spokes | Router appliance instances that are associated with the spoke. | <pre>map(object({<br> instances = set(object({<br> virtual_machine = string<br> ip_address = string<br> }))<br> location = string<br> site_to_site_data_transfer = optional(bool, false)<br> description = optional(string)<br> labels = optional(map(string))<br> include_import_ranges = optional(list(string), [])<br> group = optional(string)<br> }))</pre> | `{}` | no |
3235
| spoke\_labels | These labels will be added to all NCC spokes | `map(string)` | `{}` | no |
33-
| vpc\_spokes | VPC network that is associated with the spoke. link\_producer\_vpc\_network: Producer VPC network that is peered with vpc network | <pre>map(object({<br> uri = string<br> exclude_export_ranges = optional(set(string), [])<br> include_export_ranges = optional(set(string), [])<br> description = optional(string)<br> labels = optional(map(string))<br><br> link_producer_vpc_network = optional(object({<br> network_name = string<br> peering = string<br> include_export_ranges = optional(list(string))<br> exclude_export_ranges = optional(list(string))<br> description = optional(string)<br> labels = optional(map(string))<br> }))<br> }))</pre> | `{}` | no |
36+
| vpc\_spokes | VPC network that is associated with the spoke. link\_producer\_vpc\_network: Producer VPC network that is peered with vpc network | <pre>map(object({<br> uri = string<br> exclude_export_ranges = optional(set(string), [])<br> include_export_ranges = optional(set(string), [])<br> description = optional(string)<br> labels = optional(map(string))<br> group = optional(string)<br><br> link_producer_vpc_network = optional(object({<br> network_name = string<br> peering = string<br> include_export_ranges = optional(list(string))<br> exclude_export_ranges = optional(list(string))<br> description = optional(string)<br> labels = optional(map(string))<br> group = optional(string)<br> }))<br> }))</pre> | `{}` | no |
3437

3538
## Outputs
3639

3740
| Name | Description |
3841
|------|-------------|
42+
| groups | All group objects |
3943
| hybrid\_spokes | All hybrid spoke objects |
4044
| ncc\_hub | The NCC Hub object |
4145
| producer\_vpc\_network\_spoke | All producer network vpc spoke objects |

modules/network-connectivity-center/metadata.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ spec:
105105
description: These labels will be added the NCC hub
106106
varType: map(string)
107107
defaultValue: {}
108+
- name: ncc_hub_preset_topology
109+
description: The topology implemented in the hub
110+
varType: string
111+
- name: ncc_hub_policy_mode
112+
description: The policy mode of the hub
113+
varType: string
114+
defaultValue: PRESET
115+
- name: ncc_groups
116+
description: Groups for Hubs using the star topolgy
117+
varType: |-
118+
map(object({
119+
name = string
120+
labels = optional(map(string))
121+
description = optional(string)
122+
auto_accept_projects = optional(list(string), [])
123+
}))
124+
defaultValue: {}
108125
- name: export_psc
109126
description: Whether Private Service Connect transitivity is enabled for the hub
110127
varType: bool
@@ -118,6 +135,7 @@ spec:
118135
include_export_ranges = optional(set(string), [])
119136
description = optional(string)
120137
labels = optional(map(string))
138+
group = optional(string)
121139
122140
link_producer_vpc_network = optional(object({
123141
network_name = string
@@ -126,6 +144,7 @@ spec:
126144
exclude_export_ranges = optional(list(string))
127145
description = optional(string)
128146
labels = optional(map(string))
147+
group = optional(string)
129148
}))
130149
}))
131150
defaultValue: {}
@@ -140,6 +159,7 @@ spec:
140159
description = optional(string)
141160
labels = optional(map(string))
142161
include_import_ranges = optional(list(string), [])
162+
group = optional(string)
143163
}))
144164
defaultValue: {}
145165
- name: router_appliance_spokes
@@ -155,13 +175,16 @@ spec:
155175
description = optional(string)
156176
labels = optional(map(string))
157177
include_import_ranges = optional(list(string), [])
178+
group = optional(string)
158179
}))
159180
defaultValue: {}
160181
- name: spoke_labels
161182
description: These labels will be added to all NCC spokes
162183
varType: map(string)
163184
defaultValue: {}
164185
outputs:
186+
- name: groups
187+
description: All group objects
165188
- name: hybrid_spokes
166189
description: All hybrid spoke objects
167190
- name: ncc_hub
@@ -204,4 +227,4 @@ spec:
204227
- servicenetworking.googleapis.com
205228
providerVersions:
206229
- source: hashicorp/google
207-
version: ">= 6.49, < 8"
230+
version: ">= 6.9, < 8"

modules/network-connectivity-center/outputs.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ output "spokes" {
6262
}
6363

6464
output "groups" {
65-
value = local.groups
65+
description = "All group objects"
66+
value = local.groups
6667
}

modules/network-connectivity-center/variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ variable "ncc_hub_labels" {
3737

3838
variable "ncc_hub_preset_topology" {
3939
description = "The topology implemented in the hub"
40-
type = string
41-
default = ""
40+
type = string
41+
default = null
4242
}
4343

4444
variable "ncc_hub_policy_mode" {
4545
description = "The policy mode of the hub"
46-
type = string
47-
default = "PRESET"
46+
type = string
47+
default = "PRESET"
4848
}
4949

5050
variable "ncc_groups" {

modules/network-connectivity-center/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ terraform {
2020
required_providers {
2121
google = {
2222
source = "hashicorp/google"
23-
version = ">= 6.49, < 8"
23+
version = ">= 6.9, < 8"
2424

2525
}
2626
}

test/integration/network_connectivity_center/network_connectivity_center_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ func TestNetworkConnectivityCenter(t *testing.T) {
3131
// net.DefaultVerify(assert) Disable due to bug in provider. Reenable it after the bug is fixed
3232
projectID := net.GetStringOutput("project_id")
3333
nccHubName := net.GetStringOutput("ncc_hub_name")
34+
nccHubStarName := net.GetStringOutput("ncc_hub_name_star")
3435

3536
op := gcloud.Run(t, "network-connectivity hubs describe ", gcloud.WithCommonArgs([]string{nccHubName, "--project", projectID, "--format", "json"}))
3637
nccSpokeStateCount := op.Get("spokeSummary.spokeStateCounts").Array()
3738
assert.Equal(1, len(nccSpokeStateCount), "should have spokes in one State")
3839
assert.Equal("ACTIVE", nccSpokeStateCount[0].Get("state").String(), "should have only active spokes")
40+
41+
groups := gcloud.Run(t, "network-connectivity hubs groups list ", gcloud.WithCommonArgs([]string{"--hub", nccHubStarName, "--project", projectID, "--format", "json"})).Get("groups").Array()
42+
assert.Equal(2, len(groups), "should have two groups")
43+
for _, group := range groups {
44+
assert.Equal("ACTIVE", group.Get("state").String(), "should have active group")
45+
}
3946
})
4047
net.Test()
4148
}

0 commit comments

Comments
 (0)