Skip to content

Commit eb569f6

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

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
99
block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1"
10-
"github.com/scaleway/scaleway-sdk-go/logger"
1110
"github.com/scaleway/scaleway-sdk-go/scw"
11+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/dsf"
1212
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1313
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality"
1414
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
@@ -52,9 +52,10 @@ func ResourceVolume() *schema.Resource {
5252
Description: "The volume size in GB",
5353
},
5454
"snapshot_id": {
55-
Type: schema.TypeString,
56-
Optional: true,
57-
Description: "The snapshot to create the volume from",
55+
Type: schema.TypeString,
56+
Optional: true,
57+
Description: "The snapshot to create the volume from",
58+
DiffSuppressFunc: dsf.Locality,
5859
},
5960
"instance_volume_id": {
6061
Type: schema.TypeString,
@@ -173,7 +174,6 @@ func ResourceBlockVolumeRead(ctx context.Context, d *schema.ResourceData, m any)
173174
snapshotID := ""
174175

175176
if volume.ParentSnapshotID != nil {
176-
logger.Debugf("found snapshot In READ %s", volume.ParentSnapshotID)
177177
_, err := api.GetSnapshot(&block.GetSnapshotRequest{
178178
SnapshotID: *volume.ParentSnapshotID,
179179
Zone: zone,

0 commit comments

Comments
 (0)