Skip to content

Commit d79ab8b

Browse files
authored
feat: added producer VPC network spoke (#634)
1 parent f10a323 commit d79ab8b

File tree

24 files changed

+518
-370
lines changed

24 files changed

+518
-370
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ docker_restore_examples:
8989
.PHONY: docker_generate_docs
9090
docker_generate_docs:
9191
docker run --rm -it \
92-
-e ENABLE_BPMETADATA \
92+
-e ENABLE_BPMETADATA=1 \
9393
-v $(CURDIR):/workspace \
9494
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
9595
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'

docs/upgrading_to_v12.0.0.md

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

examples/network_connectivity_center/main.tf

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
module "network_connectivity_center" {
18-
source = "terraform-google-modules/network/google//modules/network-connectivity-center"
18+
source = "terraform-google-modules/network/google//modules/network-connectivity-center"
19+
version = "~> 12.0"
20+
1921
project_id = var.project_id
2022
ncc_hub_name = var.ncc_hub_name
2123
ncc_hub_labels = {
@@ -24,14 +26,33 @@ module "network_connectivity_center" {
2426
spoke_labels = {
2527
"created-by" = "terraform-google-ncc-example"
2628
}
29+
2730
vpc_spokes = {
2831
"vpc-1" = {
2932
uri = module.vpc_spoke_vpc.network_id
3033
labels = {
3134
"spoke-type" = "vpc"
3235
}
3336
}
37+
"producer-conn" = {
38+
uri = google_compute_network.producer_connected_network.id
39+
labels = {
40+
"spoke-type" = "producer-connected"
41+
}
42+
link_producer_vpc_network = {
43+
network_name = google_compute_network.producer_connected_network.name
44+
peering = google_service_networking_connection.producer_connected_network_peering.peering
45+
labels = {
46+
"spoke-type" = "linked-producer"
47+
}
48+
exclude_export_ranges = [
49+
"198.51.100.0/24",
50+
"10.10.0.0/16"
51+
]
52+
}
53+
}
3454
}
55+
3556
hybrid_spokes = {
3657
"vpn-1" = {
3758
type = "vpn"
@@ -245,3 +266,28 @@ resource "google_compute_instance" "router_appliance_1" {
245266
}
246267
}
247268
}
269+
270+
################################
271+
# Producer VPC Spoke #
272+
################################
273+
resource "google_compute_network" "producer_connected_network" {
274+
name = "producer-connected-network"
275+
project = var.project_id
276+
auto_create_subnetworks = false
277+
}
278+
279+
resource "google_compute_global_address" "producer_connected_network_psa_ip" {
280+
name = "producer-connected-network-psa"
281+
project = var.project_id
282+
purpose = "VPC_PEERING"
283+
address_type = "INTERNAL"
284+
prefix_length = 16
285+
network = google_compute_network.producer_connected_network.id
286+
}
287+
288+
resource "google_service_networking_connection" "producer_connected_network_peering" {
289+
network = google_compute_network.producer_connected_network.id
290+
service = "servicenetworking.googleapis.com"
291+
deletion_policy = "ABANDON"
292+
reserved_peering_ranges = [google_compute_global_address.producer_connected_network_psa_ip.name]
293+
}

examples/network_connectivity_center/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616

1717
terraform {
18-
required_version = ">=0.13.0"
18+
required_version = ">=1.3.0"
1919

2020
required_providers {
2121
google = {
2222
source = "hashicorp/google"
23-
version = ">= 5.40.0"
23+
version = ">= 6.49"
2424

2525
}
2626
}

metadata.yaml

Lines changed: 85 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Google LLC
1+
# Copyright 2025 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -118,28 +118,62 @@ spec:
118118
location: examples/submodule_vpc_serverless_connector
119119
interfaces:
120120
variables:
121-
- name: auto_create_subnetworks
122-
description: When set to true, the network is created in 'auto subnet mode' and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in 'custom subnet mode' so the user can explicitly connect subnetwork resources.
123-
varType: bool
124-
defaultValue: false
125-
- name: delete_default_internet_gateway_routes
126-
description: If set, ensure that all routes within the network specified whose names begin with 'default-route' and with a next hop of 'default-internet-gateway' are deleted
121+
- name: project_id
122+
description: The ID of the project where this VPC will be created
123+
varType: string
124+
required: true
125+
- name: network_name
126+
description: The name of the network being created
127+
varType: string
128+
required: true
129+
- name: routing_mode
130+
description: The network routing mode (default 'GLOBAL')
131+
varType: string
132+
defaultValue: GLOBAL
133+
- name: shared_vpc_host
134+
description: Makes this project a Shared VPC host if 'true' (default 'false')
127135
varType: bool
128136
defaultValue: false
129-
- name: description
130-
description: An optional description of this resource. The resource must be recreated to modify this field.
131-
varType: string
132-
defaultValue: ""
133-
- name: egress_rules
134-
description: List of egress rules. This will be ignored if variable 'rules' is non-empty
137+
- name: subnets
138+
description: The list of subnets being created
139+
varType: |-
140+
list(object({
141+
subnet_name = string
142+
subnet_ip = string
143+
subnet_region = string
144+
subnet_private_access = optional(string)
145+
subnet_private_ipv6_access = optional(string)
146+
subnet_flow_logs = optional(string)
147+
subnet_flow_logs_interval = optional(string)
148+
subnet_flow_logs_sampling = optional(string)
149+
subnet_flow_logs_metadata = optional(string)
150+
subnet_flow_logs_filter = optional(string)
151+
subnet_flow_logs_metadata_fields = optional(list(string))
152+
description = optional(string)
153+
purpose = optional(string)
154+
role = optional(string)
155+
stack_type = optional(string)
156+
ipv6_access_type = optional(string)
157+
}))
158+
required: true
159+
- name: secondary_ranges
160+
description: Secondary ranges that will be used in some of the subnets
161+
varType: map(list(object({ range_name = string, ip_cidr_range = string })))
162+
defaultValue: {}
163+
- name: routes
164+
description: List of routes being created in this VPC
165+
varType: list(map(string))
166+
defaultValue: []
167+
- name: firewall_rules
168+
description: This is DEPRECATED and available for backward compatibility. Use ingress_rules and egress_rules variables. List of firewall rules
135169
varType: |-
136170
list(object({
137171
name = string
138172
description = optional(string, null)
173+
direction = optional(string, "INGRESS")
139174
disabled = optional(bool, null)
140175
priority = optional(number, null)
141-
destination_ranges = optional(list(string), [])
142-
source_ranges = optional(list(string), [])
176+
ranges = optional(list(string), [])
143177
source_tags = optional(list(string))
144178
source_service_accounts = optional(list(string))
145179
target_tags = optional(list(string))
@@ -158,20 +192,32 @@ spec:
158192
}))
159193
}))
160194
defaultValue: []
161-
- name: enable_ipv6_ula
162-
description: Enabled IPv6 ULA, this is a permanent change and cannot be undone! (default 'false')
195+
- name: delete_default_internet_gateway_routes
196+
description: If set, ensure that all routes within the network specified whose names begin with 'default-route' and with a next hop of 'default-internet-gateway' are deleted
163197
varType: bool
164198
defaultValue: false
165-
- name: firewall_rules
166-
description: This is DEPRECATED and available for backward compatibility. Use ingress_rules and egress_rules variables. List of firewall rules
199+
- name: description
200+
description: An optional description of this resource. The resource must be recreated to modify this field.
201+
varType: string
202+
defaultValue: ""
203+
- name: auto_create_subnetworks
204+
description: When set to true, the network is created in 'auto subnet mode' and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in 'custom subnet mode' so the user can explicitly connect subnetwork resources.
205+
varType: bool
206+
defaultValue: false
207+
- name: mtu
208+
description: "The network MTU (If set to 0, meaning MTU is unset - defaults to '1460'). Recommended values: 1460 (default for historic reasons), 1500 (Internet default), or 8896 (for Jumbo packets). Allowed are all values in the range 1300 to 8896, inclusively."
209+
varType: number
210+
defaultValue: 0
211+
- name: ingress_rules
212+
description: List of ingress rules. This will be ignored if variable 'rules' is non-empty
167213
varType: |-
168214
list(object({
169215
name = string
170216
description = optional(string, null)
171-
direction = optional(string, "INGRESS")
172217
disabled = optional(bool, null)
173218
priority = optional(number, null)
174-
ranges = optional(list(string), [])
219+
destination_ranges = optional(list(string), [])
220+
source_ranges = optional(list(string), [])
175221
source_tags = optional(list(string))
176222
source_service_accounts = optional(list(string))
177223
target_tags = optional(list(string))
@@ -190,8 +236,8 @@ spec:
190236
}))
191237
}))
192238
defaultValue: []
193-
- name: ingress_rules
194-
description: List of ingress rules. This will be ignored if variable 'rules' is non-empty
239+
- name: egress_rules
240+
description: List of egress rules. This will be ignored if variable 'rules' is non-empty
195241
varType: |-
196242
list(object({
197243
name = string
@@ -218,20 +264,16 @@ spec:
218264
}))
219265
}))
220266
defaultValue: []
267+
- name: enable_ipv6_ula
268+
description: Enabled IPv6 ULA, this is a permanent change and cannot be undone! (default 'false')
269+
varType: bool
270+
defaultValue: false
221271
- name: internal_ipv6_range
222272
description: When enabling IPv6 ULA, optionally, specify a /48 from fd20::/20 (default null)
223273
varType: string
224-
- name: mtu
225-
description: "The network MTU (If set to 0, meaning MTU is unset - defaults to '1460'). Recommended values: 1460 (default for historic reasons), 1500 (Internet default), or 8896 (for Jumbo packets). Allowed are all values in the range 1300 to 8896, inclusively."
226-
varType: number
227-
defaultValue: 0
228274
- name: network_firewall_policy_enforcement_order
229275
description: Set the order that Firewall Rules and Firewall Policies are evaluated. Valid values are `BEFORE_CLASSIC_FIREWALL` and `AFTER_CLASSIC_FIREWALL`. (default null or equivalent to `AFTER_CLASSIC_FIREWALL`)
230276
varType: string
231-
- name: network_name
232-
description: The name of the network being created
233-
varType: string
234-
required: true
235277
- name: network_profile
236278
description: |
237279
"A full or partial URL of the network profile to apply to this network.
@@ -240,48 +282,17 @@ spec:
240282
* https://www.googleapis.com/compute/beta/projects/{projectId}/global/networkProfiles/{network_profile_name}
241283
* projects/{projectId}/global/networkProfiles/{network_profile_name}
242284
varType: string
243-
- name: project_id
244-
description: The ID of the project where this VPC will be created
245-
varType: string
246-
required: true
247-
- name: routes
248-
description: List of routes being created in this VPC
249-
varType: list(map(string))
250-
defaultValue: []
251-
- name: routing_mode
252-
description: The network routing mode (default 'GLOBAL')
253-
varType: string
254-
defaultValue: GLOBAL
255-
- name: secondary_ranges
256-
description: Secondary ranges that will be used in some of the subnets
257-
varType: map(list(object({ range_name = string, ip_cidr_range = string })))
258-
defaultValue: {}
259-
- name: shared_vpc_host
260-
description: Makes this project a Shared VPC host if 'true' (default 'false')
285+
- name: bgp_always_compare_med
286+
description: If set to true, the Cloud Router will use MED values from the peer even if the AS paths differ. Default is false.
261287
varType: bool
262288
defaultValue: false
263-
- name: subnets
264-
description: The list of subnets being created
265-
varType: |-
266-
list(object({
267-
subnet_name = string
268-
subnet_ip = string
269-
subnet_region = string
270-
subnet_private_access = optional(string)
271-
subnet_private_ipv6_access = optional(string)
272-
subnet_flow_logs = optional(string)
273-
subnet_flow_logs_interval = optional(string)
274-
subnet_flow_logs_sampling = optional(string)
275-
subnet_flow_logs_metadata = optional(string)
276-
subnet_flow_logs_filter = optional(string)
277-
subnet_flow_logs_metadata_fields = optional(list(string))
278-
description = optional(string)
279-
purpose = optional(string)
280-
role = optional(string)
281-
stack_type = optional(string)
282-
ipv6_access_type = optional(string)
283-
}))
284-
required: true
289+
- name: bgp_best_path_selection_mode
290+
description: Specifies the BGP best path selection mode. Valid values are `STANDARD` or `LEGACY`. Default is `LEGACY`.
291+
varType: string
292+
defaultValue: LEGACY
293+
- name: bgp_inter_region_cost
294+
description: Specifies the BGP inter-region cost mode. Valid values are `DEFAULT` or `ADD_COST_TO_MED`.
295+
varType: string
285296
outputs:
286297
- name: network
287298
description: The created network
@@ -340,8 +351,9 @@ spec:
340351
- networksecurity.googleapis.com
341352
- networkconnectivity.googleapis.com
342353
- iam.googleapis.com
354+
- servicenetworking.googleapis.com
343355
providerVersions:
344356
- source: hashicorp/google
345-
version: ">= 4.64, < 7"
357+
version: ">= 4.64, < 8"
346358
- source: hashicorp/google-beta
347-
version: ">= 4.64, < 7"
359+
version: ">= 4.64, < 8"

0 commit comments

Comments
 (0)