|
7 | 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" |
8 | 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
9 | 9 | block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" |
| 10 | + "github.com/scaleway/scaleway-sdk-go/logger" |
10 | 11 | "github.com/scaleway/scaleway-sdk-go/scw" |
11 | | - "github.com/scaleway/terraform-provider-scaleway/v2/internal/dsf" |
12 | 12 | "github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors" |
13 | 13 | "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality" |
14 | 14 | "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal" |
@@ -52,11 +52,9 @@ func ResourceVolume() *schema.Resource { |
52 | 52 | Description: "The volume size in GB", |
53 | 53 | }, |
54 | 54 | "snapshot_id": { |
55 | | - Type: schema.TypeString, |
56 | | - Optional: true, |
57 | | - ForceNew: true, |
58 | | - Description: "The snapshot to create the volume from", |
59 | | - DiffSuppressFunc: dsf.Locality, |
| 55 | + Type: schema.TypeString, |
| 56 | + Optional: true, |
| 57 | + Description: "The snapshot to create the volume from", |
60 | 58 | }, |
61 | 59 | "instance_volume_id": { |
62 | 60 | Type: schema.TypeString, |
@@ -175,14 +173,14 @@ func ResourceBlockVolumeRead(ctx context.Context, d *schema.ResourceData, m any) |
175 | 173 | snapshotID := "" |
176 | 174 |
|
177 | 175 | if volume.ParentSnapshotID != nil { |
178 | | - id := *volume.ParentSnapshotID |
| 176 | + logger.Debugf("found snapshot In READ %s", volume.ParentSnapshotID) |
179 | 177 | _, err := api.GetSnapshot(&block.GetSnapshotRequest{ |
180 | | - SnapshotID: id, |
| 178 | + SnapshotID: *volume.ParentSnapshotID, |
181 | 179 | Zone: zone, |
182 | 180 | }) |
183 | 181 |
|
184 | | - if !httperrors.Is403(err) && !httperrors.Is404(err) { |
185 | | - snapshotID = zonal.NewIDString(zone, id) |
| 182 | + if err == nil || (!httperrors.Is403(err) && !httperrors.Is404(err)) { |
| 183 | + snapshotID = zonal.NewIDString(zone, *volume.ParentSnapshotID) |
186 | 184 | } |
187 | 185 | } |
188 | 186 |
|
|
0 commit comments