From efea475a7d3ce07e7a0ad0f532b5505123a53587 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Sun, 1 Dec 2024 19:56:56 -0800 Subject: [PATCH] compute: added `subnetwork_id` to compute subnet data source Added `subnetwork_id` to `google_compute_subnetwork` data source Picked from #12285 Followup to #12351 Related to hashicorp/terraform-provider-google#20223 --- .../compute/data_source_google_compute_subnetwork.go.tmpl | 8 ++++++++ .../compute/data_source_google_compute_subnetwork_test.go | 1 + .../website/docs/d/compute_subnetwork.html.markdown | 2 ++ 3 files changed, 11 insertions(+) diff --git a/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork.go.tmpl b/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork.go.tmpl index 4315751f0b08..cfd54e7e8895 100644 --- a/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork.go.tmpl @@ -31,6 +31,10 @@ func DataSourceGoogleComputeSubnetwork() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "subnetwork_id": { + Type: schema.TypeInt, + Computed: true, + }, "ip_cidr_range": { Type: schema.TypeString, Computed: true, @@ -100,6 +104,10 @@ func dataSourceGoogleComputeSubnetworkRead(d *schema.ResourceData, meta interfac return transport_tpg.HandleDataSourceNotFoundError(err, d, fmt.Sprintf("Subnetwork Not Found : %s", name), id) } + if err := d.Set("subnetwork_id", subnetwork.Id); err != nil { + return fmt.Errorf("Error setting subnetwork_id: %s", err) + } + if err := d.Set("ip_cidr_range", subnetwork.IpCidrRange); err != nil { return fmt.Errorf("Error setting ip_cidr_range: %s", err) } diff --git a/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork_test.go b/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork_test.go index 4b7f39a5979a..a2e2d293c8c8 100644 --- a/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork_test.go +++ b/mmv1/third_party/terraform/services/compute/data_source_google_compute_subnetwork_test.go @@ -47,6 +47,7 @@ func testAccDataSourceGoogleSubnetworkCheck(data_source_name string, resource_na "id", "name", "description", + "subnetwork_id", "ip_cidr_range", "private_ip_google_access", "internal_ipv6_prefix", diff --git a/mmv1/third_party/terraform/website/docs/d/compute_subnetwork.html.markdown b/mmv1/third_party/terraform/website/docs/d/compute_subnetwork.html.markdown index 3a2b43e35fdc..34e8b5f4f3a0 100644 --- a/mmv1/third_party/terraform/website/docs/d/compute_subnetwork.html.markdown +++ b/mmv1/third_party/terraform/website/docs/d/compute_subnetwork.html.markdown @@ -40,6 +40,8 @@ In addition to the arguments listed above, the following attributes are exported * `network` - The network name or resource link to the parent network of this subnetwork. +* `subnetwork_id` - The numeric ID of the resource. + * `description` - Description of this subnetwork. * `ip_cidr_range` - The IP address range that machines in this