Skip to content

Commit 305bdc4

Browse files
committed
Fix hcloud_volume resource: Automount did not work when changing an already existing volume
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
1 parent b2979b4 commit 305bdc4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

CHANGELOG.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
## unreleased
22

33
BUG FIXES:
4-
* `hcloud_volume` datasource: id is now marked as computed to allow more setups where the id is unkown
5-
* `hcloud_ssh_key` datasource: id is now marked as computed to allow more setups where the id is unkown
6-
* `hcloud_network` datasource: id is now marked as computed to allow more setups where the id is unkown
7-
* `hcloud_image` datasource: id is now marked as computed to allow more setups where the id is unkown
8-
* `hcloud_certificate` datasource: id is now marked as computed to allow more setups where the id is unkown
4+
* `hcloud_volume` datasource: id is now marked as computed to allow more setups where the id is unknown
5+
* `hcloud_ssh_key` datasource: id is now marked as computed to allow more setups where the id is unknown
6+
* `hcloud_network` datasource: id is now marked as computed to allow more setups where the id is unknown
7+
* `hcloud_image` datasource: id is now marked as computed to allow more setups where the id is unknown
8+
* `hcloud_certificate` datasource: id is now marked as computed to allow more setups where the id is unknown
9+
* `hcloud_volume` resource: Automount is now working when you attach an already existing volume to a server.
910

1011
## 1.24.0 (January 12, 2021)
1112

internal/volume/resource.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,12 @@ func resourceVolumeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
242242
}
243243
}
244244
err := control.Retry(control.DefaultRetries, func() error {
245-
action, _, err := c.Volume.Attach(ctx, volume, &hcloud.Server{ID: serverID})
245+
opts := hcloud.VolumeAttachOpts{Server: &hcloud.Server{ID: serverID}}
246+
if automount, ok := d.GetOk("automount"); ok {
247+
opts.Automount = hcloud.Bool(automount.(bool))
248+
}
249+
250+
action, _, err := c.Volume.AttachWithOpts(ctx, volume, opts)
246251
if err != nil {
247252
if resourceVolumeIsNotFound(err, d) {
248253
return nil

0 commit comments

Comments
 (0)