Skip to content

Commit f64ff0d

Browse files
Add support to create NCC Gateway Spoke (#15198)
1 parent 12a52c4 commit f64ff0d

File tree

14 files changed

+248
-10
lines changed

14 files changed

+248
-10
lines changed

mmv1/products/compute/Router.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ examples:
7474
exclude_docs: true
7575
ignore_read_extra:
7676
- 'advertisedIpRanges'
77+
- name: 'router_ncc_gw'
78+
min_version: beta
79+
primary_resource_id: 'foobar'
80+
vars:
81+
router_name: 'my-router'
82+
network_name: 'net-spoke'
83+
hub_name: 'hub'
84+
ncc_gw_name: 'my-ncc-gw'
7785
parameters:
7886
- name: 'region'
7987
type: ResourceRef
@@ -112,7 +120,6 @@ properties:
112120
type: ResourceRef
113121
description: |
114122
A reference to the network to which this router belongs.
115-
required: true
116123
immutable: true
117124
# TODO: Figure out the story for interfaces/bgpPeers. Right
118125
# now in Terraform we have three separate resources: router,
@@ -124,6 +131,8 @@ properties:
124131
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl'
125132
resource: 'Network'
126133
imports: 'selfLink'
134+
conflicts:
135+
- nccGateway
127136
- name: 'bgp'
128137
type: NestedObject
129138
description: |
@@ -233,6 +242,16 @@ properties:
233242
description: |
234243
Value of the key used for MD5 authentication.
235244
required: true
245+
- name: 'nccGateway'
246+
type: ResourceRef
247+
description: |
248+
A URI of an NCC Gateway spoke
249+
min_version: 'beta'
250+
immutable: true
251+
resource: 'Spoke'
252+
custom_expand: 'templates/terraform/custom_expand/self_link_from_name_network_connectivity.tmpl'
253+
conflicts:
254+
- network
236255
- name: 'params'
237256
type: NestedObject
238257
ignore_read: true

mmv1/products/networkconnectivity/Hub.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ properties:
112112
enum_values:
113113
- 'MESH'
114114
- 'STAR'
115+
- 'HYBRID_INSPECTION'
115116
default_from_api: true
116117
- name: 'policyMode'
117118
type: Enum

mmv1/products/networkconnectivity/Spoke.yaml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ description: "The NetworkConnectivity Spoke resource"
1717
references:
1818
guides:
1919
'Official Documentation': 'https://cloud.google.com/network-connectivity/docs/network-connectivity-center/concepts/overview'
20-
api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1beta/projects.locations.spokes'
20+
api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1/projects.locations.spokes'
2121
docs:
2222
base_url: 'projects/{{project}}/locations/{{location}}/spokes'
2323
self_link: 'projects/{{project}}/locations/{{location}}/spokes/{{name}}'
@@ -110,6 +110,13 @@ examples:
110110
network_name: 'net'
111111
hub_name: 'hub1'
112112
spoke_name: 'spoke1-ipv6'
113+
- name: 'network_connectivity_spoke_gateway'
114+
primary_resource_id: 'primary'
115+
min_version: beta
116+
vars:
117+
network_name: 'net-spoke'
118+
hub_name: 'hub'
119+
spoke_name: 'gateway'
113120
parameters:
114121
- name: 'location'
115122
type: String
@@ -148,6 +155,7 @@ properties:
148155
- name: 'group'
149156
type: String
150157
description: The name of the group that this spoke is associated with.
158+
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
151159
immutable: true
152160
default_from_api: true
153161
- name: 'linkedVpnTunnels'
@@ -158,6 +166,7 @@ properties:
158166
- linked_router_appliance_instances
159167
- linked_vpc_network
160168
- linked_producer_vpc_network
169+
- gateway
161170
update_mask_fields:
162171
- 'linkedVpnTunnels.includeImportRanges'
163172
properties:
@@ -188,6 +197,7 @@ properties:
188197
- linked_router_appliance_instances
189198
- linked_vpc_network
190199
- linked_producer_vpc_network
200+
- gateway
191201
update_mask_fields:
192202
- 'linkedInterconnectAttachments.includeImportRanges'
193203
properties:
@@ -218,6 +228,7 @@ properties:
218228
- linked_vpn_tunnels
219229
- linked_vpc_network
220230
- linked_producer_vpc_network
231+
- gateway
221232
update_mask_fields:
222233
- 'linkedRouterApplianceInstances.instances'
223234
- 'linkedRouterApplianceInstances.includeImportRanges'
@@ -259,6 +270,7 @@ properties:
259270
- linked_router_appliance_instances
260271
- linked_vpn_tunnels
261272
- linked_producer_vpc_network
273+
- gateway
262274
update_mask_fields:
263275
- 'linkedVpcNetwork.excludeExportRanges'
264276
- 'linkedVpcNetwork.includeExportRanges'
@@ -288,6 +300,7 @@ properties:
288300
- linked_router_appliance_instances
289301
- linked_vpn_tunnels
290302
- linked_vpc_network
303+
- gateway
291304
properties:
292305
- name: network
293306
type: String
@@ -315,6 +328,47 @@ properties:
315328
description: IP ranges encompassing the subnets to be excluded from peering.
316329
item_type:
317330
type: String
331+
- name: gateway
332+
type: NestedObject
333+
description: This is a gateway that can apply specialized processing to traffic going through it.
334+
immutable: true
335+
min_version: beta
336+
conflicts:
337+
- linked_interconnect_attachments
338+
- linked_router_appliance_instances
339+
- linked_vpn_tunnels
340+
- linked_vpc_network
341+
- linkedProducerVpcNetwork
342+
properties:
343+
- name: ipRangeReservations
344+
type: Array
345+
description: A list of IP ranges that are reserved for this gateway's internal infrastructure.
346+
required: true
347+
immutable: true
348+
item_type:
349+
type: NestedObject
350+
properties:
351+
- name: ipRange
352+
type: String
353+
description: A block of IP address ranges used to allocate supporting infrastructure for this gateway—for example, 10.1.2.0/23. The IP address block must be a /23 range. This IP address block must not overlap with subnets in any spoke or peer network that the gateway can communicate with.
354+
required: true
355+
immutable: true
356+
- name: capacity
357+
type: Enum
358+
description: the capacity of the gateway spoke, in Gbps.
359+
required: true
360+
enum_values:
361+
- 'CAPACITY_1_GBPS'
362+
- 'CAPACITY_10_GBPS'
363+
- 'CAPACITY_100_GBPS'
364+
- name: routers
365+
type: Array
366+
description: Set of Cloud Routers that are attached to this NCC-GW
367+
min_version: beta
368+
item_type:
369+
type: String
370+
description: Cloud Router that is attached to the NCC-GW
371+
output: true
318372
- name: 'uniqueId'
319373
type: String
320374
description: Output only. The Google-generated UUID for the spoke. This value is unique across all spoke resources. If a spoke is deleted and another with the same name is created, the new spoke is assigned a different unique_id.

mmv1/products/networkconnectivity/product.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ display_name: 'Network Connectivity'
1717
versions:
1818
- name: 'ga'
1919
base_url: 'https://networkconnectivity.googleapis.com/v1/'
20+
- name: 'beta'
21+
base_url: 'https://networkconnectivity.googleapis.com/v1beta/'
2022
scopes:
2123
- 'https://www.googleapis.com/auth/cloud-platform'
File renamed without changes.

mmv1/products/networkconnectivity/ServiceConnectionPolicy.yaml renamed to mmv1/products/networkconnectivityv1/ServiceConnectionPolicy.yaml

File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'NetworkConnectivityv1'
16+
legacy_name: 'network_connectivity'
17+
display_name: 'Network Connectivity'
18+
versions:
19+
- name: 'ga'
20+
base_url: 'https://networkconnectivity.googleapis.com/v1/'
21+
scopes:
22+
- 'https://www.googleapis.com/auth/cloud-platform'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{/*
2+
The license inside this block applies to this file
3+
Copyright 2024 Google Inc.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/ -}}
13+
func expand{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
14+
// This method returns a full self link from a partial self link.
15+
if v == nil || v.(string) == "" {
16+
// It does not try to construct anything from empty.
17+
return "", nil
18+
} else if strings.HasPrefix(v.(string), "https://") {
19+
// Anything that starts with a URL scheme is assumed to be a self link worth using.
20+
return v, nil
21+
}
22+
// Anything else is assumed to be a regional resource, with a partial link that begins with the resource name.
23+
// This isn't very likely - it's a last-ditch effort to extract something useful here. We can do a better job
24+
// as soon as MultiResourceRefs are working since we'll know the types that this field is supposed to point to.
25+
url, err := tpgresource.ReplaceVars(d, config, "{{"{{"}}NetworkConnectivityBasePath{{"}}"}}")
26+
if err != nil {
27+
return nil, err
28+
}
29+
return url + v.(string), nil
30+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
resource "google_compute_network" "network" {
2+
provider = google-beta
3+
name = "{{index $.Vars "network_name"}}"
4+
auto_create_subnetworks = false
5+
}
6+
7+
resource "google_compute_subnetwork" "subnetwork" {
8+
provider = google-beta
9+
name = "tf-test-subnet%{random_suffix}"
10+
ip_cidr_range = "10.0.0.0/28"
11+
region = "us-central1"
12+
network = google_compute_network.network.self_link
13+
}
14+
15+
resource "google_network_connectivity_hub" "basic_hub" {
16+
provider = google-beta
17+
name = "{{index $.Vars "hub_name"}}"
18+
description = "A sample hub"
19+
labels = {
20+
label-two = "value-one"
21+
}
22+
preset_topology = "HYBRID_INSPECTION"
23+
}
24+
25+
resource "google_network_connectivity_spoke" "primary" {
26+
provider = google-beta
27+
name = "{{index $.Vars "spoke_name"}}"
28+
location = "us-central1"
29+
description = "A sample spoke of type Gateway"
30+
labels = {
31+
label-one = "value-one"
32+
}
33+
hub = google_network_connectivity_hub.basic_hub.id
34+
gateway {
35+
ip_range_reservations {
36+
ip_range = "10.0.0.0/23"
37+
}
38+
capacity = "CAPACITY_1_GBPS"
39+
}
40+
group = "gateways"
41+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
resource "google_compute_network" "network" {
2+
provider = google-beta
3+
name = "{{index $.Vars "network_name"}}"
4+
auto_create_subnetworks = false
5+
}
6+
7+
resource "google_compute_subnetwork" "subnetwork" {
8+
provider = google-beta
9+
name = "tf-test-subnet%{random_suffix}"
10+
ip_cidr_range = "10.0.0.0/28"
11+
region = "us-central1"
12+
network = google_compute_network.network.self_link
13+
}
14+
15+
resource "google_network_connectivity_hub" "basic_hub" {
16+
provider = google-beta
17+
name = "{{index $.Vars "hub_name"}}"
18+
description = "A sample hub"
19+
labels = {
20+
label-two = "value-one"
21+
}
22+
preset_topology = "HYBRID_INSPECTION"
23+
}
24+
25+
resource "google_network_connectivity_spoke" "primary" {
26+
provider = google-beta
27+
name = "{{index $.Vars "ncc_gw_name"}}"
28+
location = "us-central1"
29+
description = "A sample spoke of type Gateway"
30+
labels = {
31+
label-one = "value-one"
32+
}
33+
hub = google_network_connectivity_hub.basic_hub.id
34+
gateway {
35+
ip_range_reservations {
36+
ip_range = "10.0.0.0/23"
37+
}
38+
capacity = "CAPACITY_1_GBPS"
39+
}
40+
group = "gateways"
41+
}
42+
43+
44+
resource "google_compute_router" "foobar" {
45+
provider = google-beta
46+
name = "{{index $.Vars "router_name"}}"
47+
bgp {
48+
asn = 64514
49+
advertise_mode = "CUSTOM"
50+
advertised_groups = ["ALL_SUBNETS"]
51+
advertised_ip_ranges {
52+
range = "1.2.3.4"
53+
}
54+
advertised_ip_ranges {
55+
range = "6.7.0.0/16"
56+
}
57+
}
58+
ncc_gateway = google_network_connectivity_spoke.primary.id
59+
}

0 commit comments

Comments
 (0)