From e6661008eb4a94a419d7595c5d626e1c5a8c1cf0 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 11 Dec 2024 21:07:08 +0000 Subject: [PATCH] compute: added `subnetwork_id` to compute subnet data source (#12461) [upstream:85d05029ab559f03b4c8cdfc199bd70a25a25618] Signed-off-by: Modular Magician --- .changelog/12461.txt | 3 +++ .../compute/data_source_google_compute_subnetwork.go | 8 ++++++++ .../compute/data_source_google_compute_subnetwork_test.go | 1 + website/docs/d/compute_subnetwork.html.markdown | 2 ++ 4 files changed, 14 insertions(+) create mode 100644 .changelog/12461.txt diff --git a/.changelog/12461.txt b/.changelog/12461.txt new file mode 100644 index 0000000000..005754d661 --- /dev/null +++ b/.changelog/12461.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +compute: added `subnetwork_id` to `google_compute_subnetwork` data source +``` \ No newline at end of file diff --git a/google-beta/services/compute/data_source_google_compute_subnetwork.go b/google-beta/services/compute/data_source_google_compute_subnetwork.go index 8be8753a2a..4806719640 100644 --- a/google-beta/services/compute/data_source_google_compute_subnetwork.go +++ b/google-beta/services/compute/data_source_google_compute_subnetwork.go @@ -29,6 +29,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, @@ -98,6 +102,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/google-beta/services/compute/data_source_google_compute_subnetwork_test.go b/google-beta/services/compute/data_source_google_compute_subnetwork_test.go index ae3bb52298..3ff6ce083b 100644 --- a/google-beta/services/compute/data_source_google_compute_subnetwork_test.go +++ b/google-beta/services/compute/data_source_google_compute_subnetwork_test.go @@ -49,6 +49,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/website/docs/d/compute_subnetwork.html.markdown b/website/docs/d/compute_subnetwork.html.markdown index 3a2b43e35f..34e8b5f4f3 100644 --- a/website/docs/d/compute_subnetwork.html.markdown +++ b/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