Skip to content

Commit 01c5dcf

Browse files
authored
chore(instance): volume/snapshot: add warning for deprecated bssd type (#3112)
* chore(instance): add warning in doc + read func for deprecated type b_ssd in snapshot/volume * lint * update possible values
1 parent a3ebff3 commit 01c5dcf

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

docs/resources/instance_snapshot.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ resource "scaleway_instance_snapshot" "snapshot" {
7272
The following arguments are supported:
7373

7474
- `volume_id` - (Optional) The ID of the volume to take a snapshot from.
75-
- `type` - (Optional) The snapshot's volume type. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD) and `unified`.
75+
- `type` - (Optional) The snapshot's volume type. The possible values are: `l_ssd` (Local SSD) and `unified`.
7676
Updates to this field will recreate a new resource.
77+
78+
~> **Important:** Snapshots of volumes with type `b_ssd` (Block SSD) are deprecated and cannot be managed using the `scaleway_instance_snapshot` resource anymore. Please use the `scaleway_block_snapshot` resource instead.
79+
If you want to migrate existing snapshots, you can visit [this page](https://www.scaleway.com/en/docs/instances/how-to/migrate-volumes-snapshots-to-sbs/) for more information.
80+
7781
- `name` - (Optional) The name of the snapshot. If not provided it will be randomly generated.
7882
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which
7983
the snapshot should be created.

docs/resources/instance_volume.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ resource "scaleway_instance_volume" "server_volume" {
2222

2323
The following arguments are supported:
2424

25-
- `type` - (Required) The type of the volume. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD), `scratch` (Local Scratch SSD).
25+
- `type` - (Required) The type of the volume. The possible values are: `l_ssd` (Local SSD), `scratch` (Local Scratch SSD).
26+
27+
~> **Important:** Volumes with type `b_ssd` (Block SSD) are deprecated and cannot be managed using the `scaleway_instance_volume` resource anymore. Please use the `scaleway_block_volume` resource instead.
28+
If you want to migrate existing volumes, you can visit [this page](https://www.scaleway.com/en/docs/instances/how-to/migrate-volumes-snapshots-to-sbs/) for more information.
29+
2630
- `size_in_gb` - (Optional) The size of the volume. Only one of `size_in_gb` and `from_snapshot_id` should be specified.
2731
- `from_snapshot_id` - (Optional) If set, the new volume will be created from this snapshot. Only one of `size_in_gb` and `from_snapshot_id` should be specified.
2832
- `name` - (Optional) The name of the volume. If not provided it will be randomly generated.

internal/services/instance/snapshot.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"time"
77

8+
"github.com/hashicorp/go-cty/cty"
89
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
910
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1011
instanceSDK "github.com/scaleway/scaleway-sdk-go/api/instance/v1"
@@ -185,6 +186,17 @@ func ResourceInstanceSnapshotRead(ctx context.Context, d *schema.ResourceData, m
185186
_ = d.Set("type", snapshot.Snapshot.VolumeType.String())
186187
_ = d.Set("tags", snapshot.Snapshot.Tags)
187188

189+
if d.Get("type").(string) == instanceSDK.VolumeVolumeTypeBSSD.String() {
190+
return diag.Diagnostics{
191+
{
192+
Severity: diag.Warning,
193+
Summary: "Snapshot type `b_ssd` is deprecated",
194+
Detail: "If you want to migrate existing snapshots, you can visit `https://www.scaleway.com/en/docs/instances/how-to/migrate-volumes-snapshots-to-sbs/` for more information.",
195+
AttributePath: cty.GetAttrPath("type"),
196+
},
197+
}
198+
}
199+
188200
return nil
189201
}
190202

internal/services/instance/volume.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77

8+
"github.com/hashicorp/go-cty/cty"
89
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
910
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1011
instanceSDK "github.com/scaleway/scaleway-sdk-go/api/instance/v1"
@@ -179,6 +180,17 @@ func ResourceInstanceVolumeRead(ctx context.Context, d *schema.ResourceData, m i
179180
_ = d.Set("server_id", nil)
180181
}
181182

183+
if d.Get("type").(string) == instanceSDK.VolumeVolumeTypeBSSD.String() {
184+
return diag.Diagnostics{
185+
{
186+
Severity: diag.Warning,
187+
Summary: "Volume type `b_ssd` is deprecated",
188+
Detail: "If you want to migrate existing volumes, you can visit `https://www.scaleway.com/en/docs/instances/how-to/migrate-volumes-snapshots-to-sbs/` for more information.",
189+
AttributePath: cty.GetAttrPath("type"),
190+
},
191+
}
192+
}
193+
182194
return nil
183195
}
184196

0 commit comments

Comments
 (0)