Skip to content

Commit 87babbb

Browse files
Network peering routes config updates (#12581) (#9320)
[upstream:f47a75e9f7c3ca3fdec451e8355938982e5f3ee5] Signed-off-by: Modular Magician <[email protected]>
1 parent 55fee19 commit 87babbb

5 files changed

+99
-8
lines changed

Diff for: .changelog/12581.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `import_subnet_routes_with_public_ip` and `export_subnet_routes_with_public_ip` fields to `google_compute_network_peering_routes_config` resource
3+
```

Diff for: google-beta/services/compute/resource_compute_network_peering_routes_config.go

+62
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ func ResourceComputeNetworkPeeringRoutesConfig() *schema.Resource {
7474
Required: true,
7575
Description: `Name of the peering.`,
7676
},
77+
"export_subnet_routes_with_public_ip": {
78+
Type: schema.TypeBool,
79+
Computed: true,
80+
Optional: true,
81+
Description: `Whether subnet routes with public IP range are exported.
82+
IPv4 special-use ranges are always exported to peers and
83+
are not controlled by this field.`,
84+
},
85+
"import_subnet_routes_with_public_ip": {
86+
Type: schema.TypeBool,
87+
Computed: true,
88+
Optional: true,
89+
Description: `Whether subnet routes with public IP range are imported.
90+
IPv4 special-use ranges are always imported from peers and
91+
are not controlled by this field.`,
92+
},
7793
"project": {
7894
Type: schema.TypeString,
7995
Optional: true,
@@ -111,6 +127,18 @@ func resourceComputeNetworkPeeringRoutesConfigCreate(d *schema.ResourceData, met
111127
} else if v, ok := d.GetOkExists("import_custom_routes"); ok || !reflect.DeepEqual(v, importCustomRoutesProp) {
112128
obj["importCustomRoutes"] = importCustomRoutesProp
113129
}
130+
exportSubnetRoutesWithPublicIpProp, err := expandNestedComputeNetworkPeeringRoutesConfigExportSubnetRoutesWithPublicIp(d.Get("export_subnet_routes_with_public_ip"), d, config)
131+
if err != nil {
132+
return err
133+
} else if v, ok := d.GetOkExists("export_subnet_routes_with_public_ip"); ok || !reflect.DeepEqual(v, exportSubnetRoutesWithPublicIpProp) {
134+
obj["exportSubnetRoutesWithPublicIp"] = exportSubnetRoutesWithPublicIpProp
135+
}
136+
importSubnetRoutesWithPublicIpProp, err := expandNestedComputeNetworkPeeringRoutesConfigImportSubnetRoutesWithPublicIp(d.Get("import_subnet_routes_with_public_ip"), d, config)
137+
if err != nil {
138+
return err
139+
} else if v, ok := d.GetOkExists("import_subnet_routes_with_public_ip"); ok || !reflect.DeepEqual(v, importSubnetRoutesWithPublicIpProp) {
140+
obj["importSubnetRoutesWithPublicIp"] = importSubnetRoutesWithPublicIpProp
141+
}
114142

115143
obj, err = resourceComputeNetworkPeeringRoutesConfigEncoder(d, meta, obj)
116144
if err != nil {
@@ -243,6 +271,12 @@ func resourceComputeNetworkPeeringRoutesConfigRead(d *schema.ResourceData, meta
243271
if err := d.Set("import_custom_routes", flattenNestedComputeNetworkPeeringRoutesConfigImportCustomRoutes(res["importCustomRoutes"], d, config)); err != nil {
244272
return fmt.Errorf("Error reading NetworkPeeringRoutesConfig: %s", err)
245273
}
274+
if err := d.Set("export_subnet_routes_with_public_ip", flattenNestedComputeNetworkPeeringRoutesConfigExportSubnetRoutesWithPublicIp(res["exportSubnetRoutesWithPublicIp"], d, config)); err != nil {
275+
return fmt.Errorf("Error reading NetworkPeeringRoutesConfig: %s", err)
276+
}
277+
if err := d.Set("import_subnet_routes_with_public_ip", flattenNestedComputeNetworkPeeringRoutesConfigImportSubnetRoutesWithPublicIp(res["importSubnetRoutesWithPublicIp"], d, config)); err != nil {
278+
return fmt.Errorf("Error reading NetworkPeeringRoutesConfig: %s", err)
279+
}
246280

247281
return nil
248282
}
@@ -281,6 +315,18 @@ func resourceComputeNetworkPeeringRoutesConfigUpdate(d *schema.ResourceData, met
281315
} else if v, ok := d.GetOkExists("import_custom_routes"); ok || !reflect.DeepEqual(v, importCustomRoutesProp) {
282316
obj["importCustomRoutes"] = importCustomRoutesProp
283317
}
318+
exportSubnetRoutesWithPublicIpProp, err := expandNestedComputeNetworkPeeringRoutesConfigExportSubnetRoutesWithPublicIp(d.Get("export_subnet_routes_with_public_ip"), d, config)
319+
if err != nil {
320+
return err
321+
} else if v, ok := d.GetOkExists("export_subnet_routes_with_public_ip"); ok || !reflect.DeepEqual(v, exportSubnetRoutesWithPublicIpProp) {
322+
obj["exportSubnetRoutesWithPublicIp"] = exportSubnetRoutesWithPublicIpProp
323+
}
324+
importSubnetRoutesWithPublicIpProp, err := expandNestedComputeNetworkPeeringRoutesConfigImportSubnetRoutesWithPublicIp(d.Get("import_subnet_routes_with_public_ip"), d, config)
325+
if err != nil {
326+
return err
327+
} else if v, ok := d.GetOkExists("import_subnet_routes_with_public_ip"); ok || !reflect.DeepEqual(v, importSubnetRoutesWithPublicIpProp) {
328+
obj["importSubnetRoutesWithPublicIp"] = importSubnetRoutesWithPublicIpProp
329+
}
284330

285331
obj, err = resourceComputeNetworkPeeringRoutesConfigEncoder(d, meta, obj)
286332
if err != nil {
@@ -376,6 +422,14 @@ func flattenNestedComputeNetworkPeeringRoutesConfigImportCustomRoutes(v interfac
376422
return v
377423
}
378424

425+
func flattenNestedComputeNetworkPeeringRoutesConfigExportSubnetRoutesWithPublicIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
426+
return v
427+
}
428+
429+
func flattenNestedComputeNetworkPeeringRoutesConfigImportSubnetRoutesWithPublicIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
430+
return v
431+
}
432+
379433
func expandNestedComputeNetworkPeeringRoutesConfigPeering(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
380434
return v, nil
381435
}
@@ -388,6 +442,14 @@ func expandNestedComputeNetworkPeeringRoutesConfigImportCustomRoutes(v interface
388442
return v, nil
389443
}
390444

445+
func expandNestedComputeNetworkPeeringRoutesConfigExportSubnetRoutesWithPublicIp(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
446+
return v, nil
447+
}
448+
449+
func expandNestedComputeNetworkPeeringRoutesConfigImportSubnetRoutesWithPublicIp(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
450+
return v, nil
451+
}
452+
391453
func resourceComputeNetworkPeeringRoutesConfigEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
392454
// Stick request in a networkPeering block as in
393455
// https://cloud.google.com/compute/docs/reference/rest/v1/networks/updatePeering

Diff for: google-beta/services/compute/resource_compute_network_peering_routes_config_generated_meta.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ api_version: 'beta'
66
api_resource_type_kind: 'Network'
77
fields:
88
- field: 'export_custom_routes'
9+
- field: 'export_subnet_routes_with_public_ip'
910
- field: 'import_custom_routes'
11+
- field: 'import_subnet_routes_with_public_ip'
1012
- field: 'network'
1113
provider_only: true
1214
- field: 'peering'

Diff for: google-beta/services/compute/resource_compute_network_peering_routes_config_generated_test.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ resource "google_compute_network_peering_routes_config" "peering_primary_routes"
5555
peering = google_compute_network_peering.peering_primary.name
5656
network = google_compute_network.network_primary.name
5757
58-
import_custom_routes = true
59-
export_custom_routes = true
58+
import_custom_routes = true
59+
export_custom_routes = true
60+
import_subnet_routes_with_public_ip = true
61+
export_subnet_routes_with_public_ip = true
6062
}
6163
6264
resource "google_compute_network_peering" "peering_primary" {
@@ -66,6 +68,8 @@ resource "google_compute_network_peering" "peering_primary" {
6668
6769
import_custom_routes = true
6870
export_custom_routes = true
71+
import_subnet_routes_with_public_ip = true
72+
export_subnet_routes_with_public_ip = true
6973
}
7074
7175
resource "google_compute_network_peering" "peering_secondary" {
@@ -118,8 +122,10 @@ resource "google_compute_network_peering_routes_config" "peering_gke_routes" {
118122
peering = google_container_cluster.private_cluster.private_cluster_config[0].peering_name
119123
network = google_compute_network.container_network.name
120124
121-
import_custom_routes = true
122-
export_custom_routes = true
125+
import_custom_routes = true
126+
export_custom_routes = true
127+
import_subnet_routes_with_public_ip = true
128+
export_subnet_routes_with_public_ip = true
123129
}
124130
125131
resource "google_compute_network" "container_network" {

Diff for: website/docs/r/compute_network_peering_routes_config.html.markdown

+22-4
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ resource "google_compute_network_peering_routes_config" "peering_primary_routes"
4545
peering = google_compute_network_peering.peering_primary.name
4646
network = google_compute_network.network_primary.name
4747
48-
import_custom_routes = true
49-
export_custom_routes = true
48+
import_custom_routes = true
49+
export_custom_routes = true
50+
import_subnet_routes_with_public_ip = true
51+
export_subnet_routes_with_public_ip = true
5052
}
5153
5254
resource "google_compute_network_peering" "peering_primary" {
@@ -56,6 +58,8 @@ resource "google_compute_network_peering" "peering_primary" {
5658
5759
import_custom_routes = true
5860
export_custom_routes = true
61+
import_subnet_routes_with_public_ip = true
62+
export_subnet_routes_with_public_ip = true
5963
}
6064
6165
resource "google_compute_network_peering" "peering_secondary" {
@@ -87,8 +91,10 @@ resource "google_compute_network_peering_routes_config" "peering_gke_routes" {
8791
peering = google_container_cluster.private_cluster.private_cluster_config[0].peering_name
8892
network = google_compute_network.container_network.name
8993
90-
import_custom_routes = true
91-
export_custom_routes = true
94+
import_custom_routes = true
95+
export_custom_routes = true
96+
import_subnet_routes_with_public_ip = true
97+
export_subnet_routes_with_public_ip = true
9298
}
9399
94100
resource "google_compute_network" "container_network" {
@@ -163,6 +169,18 @@ The following arguments are supported:
163169
- - -
164170

165171

172+
* `export_subnet_routes_with_public_ip` -
173+
(Optional)
174+
Whether subnet routes with public IP range are exported.
175+
IPv4 special-use ranges are always exported to peers and
176+
are not controlled by this field.
177+
178+
* `import_subnet_routes_with_public_ip` -
179+
(Optional)
180+
Whether subnet routes with public IP range are imported.
181+
IPv4 special-use ranges are always imported from peers and
182+
are not controlled by this field.
183+
166184
* `project` - (Optional) The ID of the project in which the resource belongs.
167185
If it is not provided, the provider project is used.
168186

0 commit comments

Comments
 (0)