Skip to content

Commit 3f5955c

Browse files
Add Feature Service attachment tunneling config (#14602) (#24385)
[upstream:8059e0b433b96f9d1184c31a4bb4e19ad61ac0a1] Signed-off-by: Modular Magician <[email protected]>
1 parent 5077798 commit 3f5955c

File tree

5 files changed

+188
-0
lines changed

5 files changed

+188
-0
lines changed

.changelog/14602.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `tunneling_config` field to `google_compute_service_attachment` resource (beta)
3+
```

google/services/compute/resource_compute_service_attachment.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,25 @@ this service attachment.`,
239239
Description: `Fingerprint of this resource. This field is used internally during
240240
updates of this resource.`,
241241
},
242+
"psc_service_attachment_id": {
243+
Type: schema.TypeList,
244+
Computed: true,
245+
Description: `An 128-bit global unique ID of the PSC service attachment.`,
246+
Elem: &schema.Resource{
247+
Schema: map[string]*schema.Schema{
248+
"high": {
249+
Type: schema.TypeString,
250+
Computed: true,
251+
Description: `The high 64 bits of the PSC service attachment ID.`,
252+
},
253+
"low": {
254+
Type: schema.TypeString,
255+
Computed: true,
256+
Description: `The low 64 bits of the PSC service attachment ID.`,
257+
},
258+
},
259+
},
260+
},
242261
"send_propagated_connection_limit_if_zero": {
243262
Type: schema.TypeBool,
244263
Optional: true,
@@ -502,6 +521,9 @@ func resourceComputeServiceAttachmentRead(d *schema.ResourceData, meta interface
502521
if err := d.Set("fingerprint", flattenComputeServiceAttachmentFingerprint(res["fingerprint"], d, config)); err != nil {
503522
return fmt.Errorf("Error reading ServiceAttachment: %s", err)
504523
}
524+
if err := d.Set("psc_service_attachment_id", flattenComputeServiceAttachmentPscServiceAttachmentId(res["pscServiceAttachmentId"], d, config)); err != nil {
525+
return fmt.Errorf("Error reading ServiceAttachment: %s", err)
526+
}
505527
if err := d.Set("connection_preference", flattenComputeServiceAttachmentConnectionPreference(res["connectionPreference"], d, config)); err != nil {
506528
return fmt.Errorf("Error reading ServiceAttachment: %s", err)
507529
}
@@ -750,6 +772,29 @@ func flattenComputeServiceAttachmentFingerprint(v interface{}, d *schema.Resourc
750772
return v
751773
}
752774

775+
func flattenComputeServiceAttachmentPscServiceAttachmentId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
776+
if v == nil {
777+
return nil
778+
}
779+
original := v.(map[string]interface{})
780+
if len(original) == 0 {
781+
return nil
782+
}
783+
transformed := make(map[string]interface{})
784+
transformed["high"] =
785+
flattenComputeServiceAttachmentPscServiceAttachmentIdHigh(original["high"], d, config)
786+
transformed["low"] =
787+
flattenComputeServiceAttachmentPscServiceAttachmentIdLow(original["low"], d, config)
788+
return []interface{}{transformed}
789+
}
790+
func flattenComputeServiceAttachmentPscServiceAttachmentIdHigh(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
791+
return v
792+
}
793+
794+
func flattenComputeServiceAttachmentPscServiceAttachmentIdLow(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
795+
return v
796+
}
797+
753798
func flattenComputeServiceAttachmentConnectionPreference(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
754799
return v
755800
}

google/services/compute/resource_compute_service_attachment_generated_meta.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ fields:
2222
- field: 'name'
2323
- field: 'nat_subnets'
2424
- field: 'propagated_connection_limit'
25+
- field: 'psc_service_attachment_id.high'
26+
- field: 'psc_service_attachment_id.low'
2527
- field: 'reconcile_connections'
2628
- field: 'region'
2729
- field: 'send_propagated_connection_limit_if_zero'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
// ----------------------------------------------------------------------------
4+
//
5+
// *** AUTO GENERATED CODE *** Type: Handwritten ***
6+
//
7+
// ----------------------------------------------------------------------------
8+
//
9+
// This code is generated by Magic Modules using the following:
10+
//
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/compute/resource_compute_service_attachment_tunneling_test.go.tmpl
12+
//
13+
// DO NOT EDIT this file directly. Any changes made to this file will be
14+
// overwritten during the next generation cycle.
15+
//
16+
// ----------------------------------------------------------------------------
17+
package compute_test

website/docs/r/compute_service_attachment.html.markdown

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,98 @@ resource "google_compute_subnetwork" "psc_ilb_nat" {
402402
ip_cidr_range = "10.1.0.0/16"
403403
}
404404
```
405+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
406+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=service_attachment_tunneling_config&open_in_editor=main.tf" target="_blank">
407+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
408+
</a>
409+
</div>
410+
## Example Usage - Service Attachment Tunneling Config
411+
412+
413+
```hcl
414+
provider "google-beta" {
415+
}
416+
417+
resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
418+
provider = google-beta
419+
420+
name = "my-psc-ilb"
421+
region = "us-west2"
422+
description = "A service attachment configured with tunneling"
423+
424+
enable_proxy_protocol = false
425+
connection_preference = "ACCEPT_AUTOMATIC"
426+
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]
427+
target_service = google_compute_forwarding_rule.psc_ilb_target_service.id
428+
429+
tunneling_config {
430+
routing_mode = "REGIONAL"
431+
encapsulation_profile = "IPV4"
432+
}
433+
}
434+
435+
resource "google_compute_forwarding_rule" "psc_ilb_target_service" {
436+
provider = google-beta
437+
438+
name = "producer-forwarding-rule"
439+
region = "us-west2"
440+
441+
load_balancing_scheme = "INTERNAL"
442+
backend_service = google_compute_region_backend_service.producer_service_backend.id
443+
all_ports = true
444+
network = google_compute_network.psc_ilb_network.name
445+
subnetwork = google_compute_subnetwork.psc_ilb_producer_subnetwork.name
446+
}
447+
448+
resource "google_compute_region_backend_service" "producer_service_backend" {
449+
provider = google-beta
450+
451+
name = "producer-service"
452+
region = "us-west2"
453+
454+
health_checks = [google_compute_health_check.producer_service_health_check.id]
455+
}
456+
457+
resource "google_compute_health_check" "producer_service_health_check" {
458+
provider = google-beta
459+
460+
name = "producer-service-health-check"
461+
462+
check_interval_sec = 1
463+
timeout_sec = 1
464+
tcp_health_check {
465+
port = "80"
466+
}
467+
}
468+
469+
resource "google_compute_network" "psc_ilb_network" {
470+
provider = google-beta
471+
472+
name = "psc-ilb-network"
473+
auto_create_subnetworks = false
474+
}
475+
476+
resource "google_compute_subnetwork" "psc_ilb_producer_subnetwork" {
477+
provider = google-beta
478+
479+
name = "psc-ilb-producer-subnetwork"
480+
region = "us-west2"
481+
482+
network = google_compute_network.psc_ilb_network.id
483+
ip_cidr_range = "10.0.0.0/16"
484+
}
485+
486+
resource "google_compute_subnetwork" "psc_ilb_nat" {
487+
provider = google-beta
488+
489+
name = "psc-ilb-nat"
490+
region = "us-west2"
491+
492+
network = google_compute_network.psc_ilb_network.id
493+
purpose = "PRIVATE_SERVICE_CONNECT"
494+
ip_cidr_range = "10.1.0.0/16"
495+
}
496+
```
405497
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
406498
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=service_attachment_cross_region_ilb&open_in_editor=main.tf" target="_blank">
407499
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
@@ -535,6 +627,11 @@ The following arguments are supported:
535627
valid domain name: "p.mycompany.com.". Current max number of domain names
536628
supported is 1.
537629

630+
* `tunneling_config` -
631+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
632+
Tunneling configuration for this service attachment.
633+
Structure is [documented below](#nested_tunneling_config).
634+
538635
* `consumer_reject_lists` -
539636
(Optional)
540637
An array of projects that are not allowed to connect to this service
@@ -574,6 +671,16 @@ Defaults to false.
574671

575672

576673

674+
<a name="nested_tunneling_config"></a>The `tunneling_config` block supports:
675+
676+
* `routing_mode` -
677+
(Optional)
678+
The routing mode for tunneling traffic.
679+
680+
* `encapsulation_profile` -
681+
(Optional)
682+
The encapsulation profile for tunneling traffic.
683+
577684
<a name="nested_consumer_accept_lists"></a>The `consumer_accept_lists` block supports:
578685

579686
* `project_id_or_num` -
@@ -601,13 +708,27 @@ In addition to the arguments listed above, the following computed attributes are
601708
Fingerprint of this resource. This field is used internally during
602709
updates of this resource.
603710

711+
* `psc_service_attachment_id` -
712+
An 128-bit global unique ID of the PSC service attachment.
713+
Structure is [documented below](#nested_psc_service_attachment_id).
714+
604715
* `connected_endpoints` -
605716
An array of the consumer forwarding rules connected to this service
606717
attachment.
607718
Structure is [documented below](#nested_connected_endpoints).
608719
* `self_link` - The URI of the created resource.
609720

610721

722+
<a name="nested_psc_service_attachment_id"></a>The `psc_service_attachment_id` block contains:
723+
724+
* `high` -
725+
(Output)
726+
The high 64 bits of the PSC service attachment ID.
727+
728+
* `low` -
729+
(Output)
730+
The low 64 bits of the PSC service attachment ID.
731+
611732
<a name="nested_connected_endpoints"></a>The `connected_endpoints` block contains:
612733

613734
* `endpoint` -

0 commit comments

Comments
 (0)