From 4306e56b2cba796827393206c5609c48698892bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=AFla=20Marabese?= Date: Mon, 26 May 2025 16:05:53 +0200 Subject: [PATCH 1/3] chore(instance): add warning in doc + read func for deprecated type b_ssd in snapshot/volume --- docs/resources/instance_snapshot.md | 4 ++++ docs/resources/instance_volume.md | 6 +++++- internal/services/instance/snapshot.go | 12 ++++++++++++ internal/services/instance/volume.go | 12 ++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/resources/instance_snapshot.md b/docs/resources/instance_snapshot.md index 9e46b5df79..e1f8ef8b6d 100644 --- a/docs/resources/instance_snapshot.md +++ b/docs/resources/instance_snapshot.md @@ -74,6 +74,10 @@ 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`. 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. diff --git a/docs/resources/instance_volume.md b/docs/resources/instance_volume.md index f29a78a255..ebde99f59d 100644 --- a/docs/resources/instance_volume.md +++ b/docs/resources/instance_volume.md @@ -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. diff --git a/internal/services/instance/snapshot.go b/internal/services/instance/snapshot.go index 2cc5eb74e2..6dd7a64102 100644 --- a/internal/services/instance/snapshot.go +++ b/internal/services/instance/snapshot.go @@ -3,6 +3,7 @@ package instance import ( "context" "fmt" + "github.com/hashicorp/go-cty/cty" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -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) == "b_ssd" { + 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 } diff --git a/internal/services/instance/volume.go b/internal/services/instance/volume.go index 9de1c7c645..0e8f3a48a2 100644 --- a/internal/services/instance/volume.go +++ b/internal/services/instance/volume.go @@ -4,6 +4,7 @@ import ( "context" "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" @@ -179,6 +180,17 @@ func ResourceInstanceVolumeRead(ctx context.Context, d *schema.ResourceData, m i _ = d.Set("server_id", nil) } + if d.Get("type").(string) == "b_ssd" { + 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 } From 0116dc5eeada37d582bce152126b7266afd1de8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=AFla=20Marabese?= Date: Mon, 26 May 2025 16:12:17 +0200 Subject: [PATCH 2/3] lint --- internal/services/instance/snapshot.go | 4 ++-- internal/services/instance/volume.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/instance/snapshot.go b/internal/services/instance/snapshot.go index 6dd7a64102..8a0232bef2 100644 --- a/internal/services/instance/snapshot.go +++ b/internal/services/instance/snapshot.go @@ -3,9 +3,9 @@ package instance import ( "context" "fmt" - "github.com/hashicorp/go-cty/cty" "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" @@ -186,7 +186,7 @@ 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) == "b_ssd" { + if d.Get("type").(string) == instanceSDK.VolumeVolumeTypeBSSD.String() { return diag.Diagnostics{ { Severity: diag.Warning, diff --git a/internal/services/instance/volume.go b/internal/services/instance/volume.go index 0e8f3a48a2..82abfff563 100644 --- a/internal/services/instance/volume.go +++ b/internal/services/instance/volume.go @@ -4,8 +4,8 @@ import ( "context" "errors" "fmt" - "github.com/hashicorp/go-cty/cty" + "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" @@ -180,7 +180,7 @@ func ResourceInstanceVolumeRead(ctx context.Context, d *schema.ResourceData, m i _ = d.Set("server_id", nil) } - if d.Get("type").(string) == "b_ssd" { + if d.Get("type").(string) == instanceSDK.VolumeVolumeTypeBSSD.String() { return diag.Diagnostics{ { Severity: diag.Warning, From c223208a998b91370c39457e776b900b72cacb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=AFla=20Marabese?= Date: Mon, 26 May 2025 16:18:16 +0200 Subject: [PATCH 3/3] update possible values --- docs/resources/instance_snapshot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/instance_snapshot.md b/docs/resources/instance_snapshot.md index e1f8ef8b6d..3d087cefee 100644 --- a/docs/resources/instance_snapshot.md +++ b/docs/resources/instance_snapshot.md @@ -72,7 +72,7 @@ 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.