Skip to content

Commit 63f871e

Browse files
add disk_id attribute in google_compute_disk resource (#9857) (#17112)
[upstream:9036b258fd1e269ebe4b6ffae9decfed02f790e7] Signed-off-by: Modular Magician <[email protected]>
1 parent 9b25415 commit 63f871e

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

.changelog/9857.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `disk_id` attribute to `google_compute_disk` resource
3+
```

google/services/compute/resource_compute_disk.go

+12
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,11 @@ create the disk. Provide this when creating the disk.`,
651651
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
652652
Description: `A reference to the zone where the disk resides.`,
653653
},
654+
"disk_id": {
655+
Type: schema.TypeString,
656+
Computed: true,
657+
Description: `The unique identifier for the resource. This identifier is defined by the server.`,
658+
},
654659
"creation_timestamp": {
655660
Type: schema.TypeString,
656661
Computed: true,
@@ -1026,6 +1031,9 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
10261031
if err := d.Set("source_disk_id", flattenComputeDiskSourceDiskId(res["sourceDiskId"], d, config)); err != nil {
10271032
return fmt.Errorf("Error reading Disk: %s", err)
10281033
}
1034+
if err := d.Set("disk_id", flattenComputeDiskDiskId(res["id"], d, config)); err != nil {
1035+
return fmt.Errorf("Error reading Disk: %s", err)
1036+
}
10291037
if err := d.Set("type", flattenComputeDiskType(res["type"], d, config)); err != nil {
10301038
return fmt.Errorf("Error reading Disk: %s", err)
10311039
}
@@ -1524,6 +1532,10 @@ func flattenComputeDiskSourceDiskId(v interface{}, d *schema.ResourceData, confi
15241532
return v
15251533
}
15261534

1535+
func flattenComputeDiskDiskId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1536+
return v
1537+
}
1538+
15271539
func flattenComputeDiskType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
15281540
if v == nil {
15291541
return v

website/docs/r/compute_disk.html.markdown

+3
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ In addition to the arguments listed above, the following computed attributes are
432432
be used to determine whether the image was taken from the current
433433
or a previous instance of a given disk name.
434434

435+
* `disk_id` -
436+
The unique identifier for the resource. This identifier is defined by the server.
437+
435438
* `terraform_labels` -
436439
The combination of labels configured directly on the resource
437440
and default labels configured on the provider.

0 commit comments

Comments
 (0)