Skip to content

Commit e32ffda

Browse files
TF NCC-GW: Make Gateway Advertised Routes Mutable (GoogleCloudPlatform#16172)
1 parent db41bf7 commit e32ffda

2 files changed

Lines changed: 175 additions & 1 deletion

File tree

mmv1/products/networkconnectivity/GatewayAdvertisedRoute.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ min_version: beta
2525
base_url: 'projects/{{project}}/locations/{{location}}/spokes/{{spoke}}/gatewayAdvertisedRoutes'
2626
self_link: 'projects/{{project}}/locations/{{location}}/spokes/{{spoke}}/gatewayAdvertisedRoutes/{{name}}'
2727
create_url: 'projects/{{project}}/locations/{{location}}/spokes/{{spoke}}/gatewayAdvertisedRoutes?gatewayAdvertisedRouteId={{name}}'
28-
immutable: true
28+
update_verb: 'PATCH'
29+
update_mask: true
30+
timeouts:
31+
insert_minutes: 20
32+
update_minutes: 20
33+
delete_minutes: 20
2934
autogen_async: true
3035
async:
3136
operation:
@@ -71,10 +76,12 @@ properties:
7176
output: true
7277
- name: 'labels'
7378
type: KeyValueLabels
79+
immutable: true
7480
description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://docs.cloud.google.com/resource-manager/docs/creating-managing-labels#requirements).
7581
- name: 'description'
7682
type: String
7783
description: An optional description of the gateway advertised route.
84+
immutable: true
7885
- name: 'uniqueId'
7986
type: String
8087
description: |
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{{ if ne $.TargetVersionName `ga` -}}
2+
package networkconnectivity_test
3+
4+
import (
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
8+
"github.com/hashicorp/terraform-provider-google/google/acctest"
9+
"github.com/hashicorp/terraform-provider-google/google/envvar"
10+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
11+
)
12+
13+
func TestAccNetworkConnectivityGatewayAdvertisedRouter_test_basic(t *testing.T) {
14+
t.Parallel()
15+
16+
context := map[string]interface{}{
17+
"project_name": envvar.GetTestProjectFromEnv(),
18+
"region": envvar.GetTestRegionFromEnv(),
19+
"random_suffix": acctest.RandString(t, 10),
20+
}
21+
22+
acctest.VcrTest(t, resource.TestCase{
23+
PreCheck: func() { acctest.AccTestPreCheck(t) },
24+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
25+
CheckDestroy: testAccCheckNetworkConnectivitySpokeDestroyProducer(t),
26+
Steps: []resource.TestStep{
27+
{
28+
Config: testAccNetworkConnectivitySpoke_test_basic(context),
29+
},
30+
{
31+
ResourceName: "google_network_connectivity_gateway_advertised_route.gateway-advertised-route",
32+
ImportState: true,
33+
ImportStateVerify: true,
34+
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
35+
},
36+
{
37+
Config: testAccNetworkConnectivitySpoke_test_update(context),
38+
ConfigPlanChecks: resource.ConfigPlanChecks{
39+
PreApply: []plancheck.PlanCheck{
40+
plancheck.ExpectResourceAction("google_network_connectivity_gateway_advertised_route.gateway-advertised-route", plancheck.ResourceActionUpdate),
41+
},
42+
},
43+
},
44+
{
45+
ResourceName: "google_network_connectivity_gateway_advertised_route.gateway-advertised-route",
46+
ImportState: true,
47+
ImportStateVerify: true,
48+
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
49+
},
50+
},
51+
})
52+
}
53+
54+
func testAccNetworkConnectivitySpoke_test_basic(context map[string]interface{}) string {
55+
return acctest.Nprintf(`
56+
57+
resource "google_compute_network" "network" {
58+
name = "tf-test-network%{random_suffix}"
59+
auto_create_subnetworks = false
60+
}
61+
62+
resource "google_compute_subnetwork" "subnetwork" {
63+
name = "tf-test-subnet%{random_suffix}"
64+
ip_cidr_range = "10.0.0.0/28"
65+
region = "us-east1"
66+
network = google_compute_network.network.self_link
67+
}
68+
69+
resource "google_network_connectivity_hub" "basic_hub" {
70+
name = "tf-test-hub%{random_suffix}"
71+
description = "A sample hub"
72+
labels = {
73+
label-two = "value-one"
74+
}
75+
preset_topology = "HYBRID_INSPECTION"
76+
}
77+
78+
resource "google_network_connectivity_spoke" "primary" {
79+
name = "tf-test-name%{random_suffix}"
80+
location = "us-east1"
81+
description = "A sample spoke with a linked routher appliance instance"
82+
labels = {
83+
label-one = "value-one"
84+
}
85+
hub = google_network_connectivity_hub.basic_hub.id
86+
gateway {
87+
ip_range_reservations {
88+
ip_range = "10.0.0.0/23"
89+
}
90+
capacity = "CAPACITY_1_GBPS"
91+
}
92+
group = "gateways"
93+
}
94+
95+
resource "google_network_connectivity_gateway_advertised_route" "gateway-advertised-route" {
96+
spoke = google_network_connectivity_spoke.primary.name
97+
location = "us-east1"
98+
name = "tf-test-gateway-advertised-route%{random_suffix}"
99+
labels = {
100+
label-one = "value-one"
101+
}
102+
description = "description of the gateway advertised route"
103+
ip_range = "0.0.0.0/24"
104+
recipient = "ADVERTISE_TO_HUB"
105+
priority = 200
106+
}
107+
`, context)
108+
}
109+
110+
func testAccNetworkConnectivitySpoke_test_update(context map[string]interface{}) string {
111+
return acctest.Nprintf(`
112+
113+
resource "google_compute_network" "network" {
114+
name = "tf-test-network%{random_suffix}"
115+
auto_create_subnetworks = false
116+
}
117+
118+
resource "google_compute_subnetwork" "subnetwork" {
119+
name = "tf-test-subnet%{random_suffix}"
120+
ip_cidr_range = "10.0.0.0/28"
121+
region = "us-east1"
122+
network = google_compute_network.network.self_link
123+
}
124+
125+
resource "google_network_connectivity_hub" "basic_hub" {
126+
name = "tf-test-hub%{random_suffix}"
127+
description = "A sample hub"
128+
labels = {
129+
label-two = "value-one"
130+
}
131+
preset_topology = "HYBRID_INSPECTION"
132+
}
133+
134+
resource "google_network_connectivity_spoke" "primary" {
135+
name = "tf-test-name%{random_suffix}"
136+
location = "us-east1"
137+
description = "A sample spoke with a linked routher appliance instance"
138+
labels = {
139+
label-one = "value-one"
140+
}
141+
hub = google_network_connectivity_hub.basic_hub.id
142+
gateway {
143+
ip_range_reservations {
144+
ip_range = "10.0.0.0/23"
145+
}
146+
capacity = "CAPACITY_1_GBPS"
147+
}
148+
group = "gateways"
149+
}
150+
151+
resource "google_network_connectivity_gateway_advertised_route" "gateway-advertised-route" {
152+
spoke = google_network_connectivity_spoke.primary.name
153+
location = "us-east1"
154+
name = "tf-test-gateway-advertised-route%{random_suffix}"
155+
labels = {
156+
label-one = "value-one"
157+
}
158+
description = "description of the gateway advertised route"
159+
ip_range = "0.0.0.0/24"
160+
recipient = "ADVERTISE_TO_HUB"
161+
priority = 100
162+
}
163+
`, context)
164+
}
165+
166+
167+
{{- end }}

0 commit comments

Comments
 (0)