Skip to content

chore(instance): volume/snapshot: add warning for deprecated bssd type #3112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/resources/instance_snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ resource "scaleway_instance_snapshot" "snapshot" {
The following arguments are supported:

- `volume_id` - (Optional) The ID of the volume to take a snapshot from.
- `type` - (Optional) The snapshot's volume type. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD) and `unified`.
- `type` - (Optional) The snapshot's volume type. The possible values are: `l_ssd` (Local SSD) and `unified`.
Updates to this field will recreate a new resource.

~> **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.
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.

- `name` - (Optional) The name of the snapshot. If not provided it will be randomly generated.
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which
the snapshot should be created.
Expand Down
6 changes: 5 additions & 1 deletion docs/resources/instance_volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ resource "scaleway_instance_volume" "server_volume" {

The following arguments are supported:

- `type` - (Required) The type of the volume. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD), `scratch` (Local Scratch SSD).
- `type` - (Required) The type of the volume. The possible values are: `l_ssd` (Local SSD), `scratch` (Local Scratch SSD).

~> **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.
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.

- `size_in_gb` - (Optional) The size of the volume. Only one of `size_in_gb` and `from_snapshot_id` should be specified.
- `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.
- `name` - (Optional) The name of the volume. If not provided it will be randomly generated.
Expand Down
12 changes: 12 additions & 0 deletions internal/services/instance/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

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

if d.Get("type").(string) == instanceSDK.VolumeVolumeTypeBSSD.String() {
return diag.Diagnostics{
{
Severity: diag.Warning,
Summary: "Snapshot type `b_ssd` is deprecated",
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.",
AttributePath: cty.GetAttrPath("type"),
},
}
}

return nil
}

Expand Down
12 changes: 12 additions & 0 deletions internal/services/instance/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"

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

if d.Get("type").(string) == instanceSDK.VolumeVolumeTypeBSSD.String() {
return diag.Diagnostics{
{
Severity: diag.Warning,
Summary: "Volume type `b_ssd` is deprecated",
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.",
AttributePath: cty.GetAttrPath("type"),
},
}
}

return nil
}

Expand Down
Loading