Skip to content

Commit

Permalink
compute: added subnetwork_id to compute subnet data source (#12461) (
Browse files Browse the repository at this point in the history
…#8893)

[upstream:85d05029ab559f03b4c8cdfc199bd70a25a25618]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 11, 2024
1 parent 3e0dc54 commit 3946a6e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/12461.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added `subnetwork_id` to `google_compute_subnetwork` data source
```
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/compute_subnetwork.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3946a6e

Please sign in to comment.