Skip to content

Commit 1861955

Browse files
authored
compute: add Global External Passthrough NetLB support (#20007)
1 parent c719218 commit 1861955

7 files changed

Lines changed: 121 additions & 6 deletions

File tree

‎mmv1/products/compute/BackendService.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ include_in_tgc_next: true
5252
tgc_tests:
5353
- name: 'TestAccComputeBackendService_backendServiceCustomMetrics_update'
5454
skip: 'Test framework problem with single vs multiple block parsing of custom_metrics'
55+
api_version:
56+
ga: '2026-11-01'
5557
custom_code:
5658
constants: 'templates/terraform/constants/backend_service.go.tmpl'
5759
encoder: 'templates/terraform/encoders/backend_service.go.tmpl'
@@ -1006,6 +1008,7 @@ properties:
10061008
- 'INTERNAL_SELF_MANAGED'
10071009
- 'INTERNAL_MANAGED'
10081010
- 'EXTERNAL_MANAGED'
1011+
- 'EXTERNAL_PASSTHROUGH'
10091012
- name: 'externalManagedMigrationState'
10101013
type: Enum
10111014
description: |

‎mmv1/products/compute/GlobalAddress.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ async:
3939
resource_inside_response: false
4040
collection_url_key: 'items'
4141
include_in_tgc_next: true
42+
api_version:
43+
ga: '2026-11-01'
4244
custom_code:
4345
pre_create: 'templates/terraform/pre_create/compute_global_address.go.tmpl'
4446
post_create: 'templates/terraform/post_create/labels.tmpl'
@@ -140,6 +142,10 @@ properties:
140142
* VPC_PEERING - for peer networks
141143
142144
* PRIVATE_SERVICE_CONNECT - for ([Beta](../guides/provider_versions.html.markdown)) only) Private Service Connect networks
145+
146+
* PASSTHROUGH_LOAD_BALANCER_AVAILABILITY_GROUP0 - for Global External Passthrough Network Load Balancers
147+
148+
* PASSTHROUGH_LOAD_BALANCER_AVAILABILITY_GROUP1 - for Global External Passthrough Network Load Balancers
143149
- name: 'network'
144150
type: ResourceRef
145151
description: |

‎mmv1/products/compute/GlobalForwardingRule.yaml‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ async:
4444
resource_inside_response: false
4545
collection_url_key: 'items'
4646
include_in_tgc_next: true
47+
api_version:
48+
ga: '2026-11-01'
4749
custom_code:
4850
pre_create: 'templates/terraform/pre_create/compute_global_forwarding_rule.go.tmpl'
4951
post_create: 'templates/terraform/post_create/labels.tmpl'
@@ -240,6 +242,20 @@ samples:
240242
- 'ip_address'
241243
parameters:
242244
properties:
245+
246+
- name: 'backendService'
247+
type: ResourceRef
248+
description: |
249+
Identifies the backend service to which the forwarding rule sends traffic.
250+
251+
Required for Global External Passthrough Network Load Balancing;
252+
must be omitted for all other load balancer types.
253+
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl'
254+
exactly_one_of:
255+
- 'backend_service'
256+
- 'target'
257+
resource: 'BackendService'
258+
imports: 'selfLink'
243259
- name: 'pscConnectionId'
244260
type: String
245261
description: 'The PSC connection id of the PSC Forwarding Rule.'
@@ -347,6 +363,16 @@ properties:
347363
update_url: 'projects/{{project}}/global/forwardingRules/{{name}}/setLabels'
348364
update_verb: 'POST'
349365
key_expander: ''
366+
- name: 'ipAddresses'
367+
api_name: 'IPAddresses'
368+
type: Array
369+
description: |
370+
IP addresses for which this forwarding rule accepts traffic, ordered by
371+
Availability Group 0 followed by Availability Group 1. Specify literal
372+
IP addresses (for example, `google_compute_global_address.example.address`).
373+
default_from_api: true
374+
item_type:
375+
type: String
350376
- name: 'loadBalancingScheme'
351377
type: Enum
352378
description: |
@@ -360,6 +386,7 @@ properties:
360386
- 'EXTERNAL_MANAGED'
361387
- 'INTERNAL_MANAGED'
362388
- 'INTERNAL_SELF_MANAGED'
389+
- 'EXTERNAL_PASSTHROUGH'
363390
update_url: 'projects/{{project}}/global/forwardingRules/{{name}}'
364391
update_verb: 'PATCH'
365392
- name: 'metadataFilters'
@@ -521,7 +548,9 @@ properties:
521548
* `all-apis` - [All supported Google APIs](https://cloud.google.com/vpc/docs/private-service-connect#supported-apis).
522549
523550
For Private Service Connect forwarding rules that forward traffic to managed services, the target must be a service attachment.
524-
required: true
551+
exactly_one_of:
552+
- 'backend_service'
553+
- 'target'
525554
update_url: 'projects/{{project}}/global/forwardingRules/{{name}}/setTarget'
526555
update_verb: 'POST'
527556
diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths'

‎mmv1/templates/terraform/post_create/compute_backend_service_security_policy.go.tmpl‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ if o, n := d.GetChange("security_policy"); o.(string) != n.(string) {
2424
UserAgent: userAgent,
2525
Body: sBody,
2626
Headers: headers,
27+
{{- if $.ApiVersion }}
28+
ApiVersion: "{{ $.ApiVersion }}",
29+
{{- end }}
2730
})
2831

2932
if err != nil {
@@ -61,6 +64,9 @@ if o, n := d.GetChange("edge_security_policy"); o.(string) != n.(string) {
6164
UserAgent: userAgent,
6265
Body: eBody,
6366
Headers: headers,
67+
{{- if $.ApiVersion }}
68+
ApiVersion: "{{ $.ApiVersion }}",
69+
{{- end }}
6470
})
6571
if err != nil {
6672
return fmt.Errorf("Error setting Backend Service edge security policy: %w", err)

‎mmv1/templates/terraform/post_create/labels.tmpl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect
3636
{{- if $.ErrorAbortPredicates }}
3737
ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{ {{- join $.ErrorAbortPredicates "," -}} },
3838
{{- end }}
39+
{{- if $.ApiVersion }}
40+
ApiVersion: "{{ $.ApiVersion }}",
41+
{{- end }}
3942
})
4043
if err != nil {
4144
return fmt.Errorf("Error adding labels to {{$.ResourceName}} %q: %s", d.Id(), err)
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Labels cannot be set in a create for PSC forwarding rules, so remove it from the CREATE request.
2-
if strings.Contains(targetProp.(string), "/serviceAttachments/") ||
3-
targetProp.(string) == "all-apis" ||
4-
targetProp.(string) == "vpc-sc" {
5-
if _, ok := obj["labels"]; ok {
6-
delete(obj, "labels")
2+
if targetStr, ok := targetProp.(string); ok {
3+
if strings.Contains(targetStr, "/serviceAttachments/") ||
4+
targetStr == "all-apis" ||
5+
targetStr == "vpc-sc" {
6+
if _, ok := obj["labels"]; ok {
7+
delete(obj, "labels")
8+
}
79
}
810
}

‎mmv1/third_party/terraform/services/compute/resource_compute_global_forwarding_rule_test.go.tmpl‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,3 +1109,69 @@ resource "google_compute_global_address" "my_global_ip" {
11091109
}
11101110
`, fr, percentage, proxy, urlmap, backendservice, address)
11111111
}
1112+
1113+
func TestAccComputeGlobalForwardingRule_ExternalPassthrough(t *testing.T) {
1114+
t.Parallel()
1115+
1116+
fr := fmt.Sprintf("tf-test-fr-%s", acctest.RandString(t, 10))
1117+
backendservice := fmt.Sprintf("tf-test-bs-%s", acctest.RandString(t, 10))
1118+
address0 := fmt.Sprintf("tf-test-addr0-%s", acctest.RandString(t, 10))
1119+
address1 := fmt.Sprintf("tf-test-addr1-%s", acctest.RandString(t, 10))
1120+
1121+
acctest.VcrTest(t, resource.TestCase{
1122+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1123+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1124+
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroyProducer(t),
1125+
Steps: []resource.TestStep{
1126+
{
1127+
Config: testAccComputeGlobalForwardingRule_externalPassthrough(fr, backendservice, address0, address1, "google_compute_backend_service.my_backend_service.name"),
1128+
},
1129+
{
1130+
ResourceName: "google_compute_global_forwarding_rule.forwarding_rule",
1131+
ImportState: true,
1132+
ImportStateVerify: true,
1133+
ImportStateVerifyIgnore: []string{"port_range"},
1134+
},
1135+
{
1136+
Config: testAccComputeGlobalForwardingRule_externalPassthrough(fr, backendservice, address0, address1, "google_compute_backend_service.my_backend_service.id"),
1137+
ConfigPlanChecks: resource.ConfigPlanChecks{
1138+
PreApply: []plancheck.PlanCheck{
1139+
plancheck.ExpectEmptyPlan(),
1140+
},
1141+
},
1142+
},
1143+
},
1144+
})
1145+
}
1146+
1147+
func testAccComputeGlobalForwardingRule_externalPassthrough(fr, backendservice, address0, address1, backendServiceRef string) string {
1148+
return fmt.Sprintf(`
1149+
resource "google_compute_global_forwarding_rule" "forwarding_rule" {
1150+
name = "%s"
1151+
ip_protocol = "TCP"
1152+
port_range = "80"
1153+
load_balancing_scheme = "EXTERNAL_PASSTHROUGH"
1154+
backend_service = %s
1155+
ip_addresses = [
1156+
google_compute_global_address.my_global_ip0.address,
1157+
google_compute_global_address.my_global_ip1.address
1158+
]
1159+
}
1160+
1161+
resource "google_compute_backend_service" "my_backend_service" {
1162+
name = "%s"
1163+
protocol = "UNSPECIFIED"
1164+
load_balancing_scheme = "EXTERNAL_PASSTHROUGH"
1165+
}
1166+
1167+
resource "google_compute_global_address" "my_global_ip0" {
1168+
name = "%s"
1169+
purpose = "PASSTHROUGH_LOAD_BALANCER_AVAILABILITY_GROUP0"
1170+
}
1171+
1172+
resource "google_compute_global_address" "my_global_ip1" {
1173+
name = "%s"
1174+
purpose = "PASSTHROUGH_LOAD_BALANCER_AVAILABILITY_GROUP1"
1175+
}
1176+
`, fr, backendServiceRef, backendservice, address0, address1)
1177+
}

0 commit comments

Comments
 (0)