Skip to content

Commit 12a6fca

Browse files
committed
fix forceNew add Locality to customDiff
1 parent 0af2be2 commit 12a6fca

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

internal/services/block/helpers_block.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/scaleway/scaleway-sdk-go/scw"
1212
"github.com/scaleway/terraform-provider-scaleway/v2/internal/dsf"
1313
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
14+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality"
1415
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
1516
"github.com/scaleway/terraform-provider-scaleway/v2/internal/meta"
1617
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/instance/instancehelpers"
@@ -69,9 +70,11 @@ func customDiffSnapshot(key string) schema.CustomizeDiffFunc {
6970
}
7071

7172
blockAPI := block.NewAPI(meta.ExtractScwClient(i))
73+
zone, id, _ := locality.ParseLocalizedID(oldValue.(string))
7274

7375
_, err := blockAPI.GetSnapshot(&block.GetSnapshotRequest{
74-
SnapshotID: oldValue.(string),
76+
SnapshotID: id,
77+
Zone: scw.Zone(zone),
7578
})
7679
if (httperrors.Is403(err) || httperrors.Is404(err)) && newValue == "" {
7780
return nil

internal/services/block/volume.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1"
1010
"github.com/scaleway/scaleway-sdk-go/logger"
1111
"github.com/scaleway/scaleway-sdk-go/scw"
12+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/dsf"
1213
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1314
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality"
1415
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
@@ -52,9 +53,10 @@ func ResourceVolume() *schema.Resource {
5253
Description: "The volume size in GB",
5354
},
5455
"snapshot_id": {
55-
Type: schema.TypeString,
56-
Optional: true,
57-
Description: "The snapshot to create the volume from",
56+
Type: schema.TypeString,
57+
Optional: true,
58+
Description: "The snapshot to create the volume from",
59+
DiffSuppressFunc: dsf.Locality,
5860
},
5961
"instance_volume_id": {
6062
Type: schema.TypeString,

0 commit comments

Comments
 (0)