From 5f769ac294da0cea155908d1377ec1d38e4627a2 Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Tue, 31 Mar 2026 16:04:50 +0200 Subject: [PATCH] fix(iaas): prevent state drift on server boot volume relates to STACKITTPR-609 and #1065 --- stackit/internal/core/core.go | 5 ++--- stackit/internal/services/iaas/server/resource.go | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/stackit/internal/core/core.go b/stackit/internal/core/core.go index acc566f1c..8def0473d 100644 --- a/stackit/internal/core/core.go +++ b/stackit/internal/core/core.go @@ -7,11 +7,10 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/runtime" - "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/stackitcloud/stackit-sdk-go/core/runtime" ) type ResourceType string diff --git a/stackit/internal/services/iaas/server/resource.go b/stackit/internal/services/iaas/server/resource.go index 9f368f610..1915d86cc 100644 --- a/stackit/internal/services/iaas/server/resource.go +++ b/stackit/internal/services/iaas/server/resource.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" iaasUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/utils" "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" @@ -314,6 +315,9 @@ func (r *serverResource) Schema(_ context.Context, _ resource.SchemaRequest, res PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, + Validators: []validator.String{ + stringvalidator.OneOf(supportedSourceTypes...), + }, }, "source_id": schema.StringAttribute{ Description: "The ID of the source, either image ID or volume ID", @@ -326,6 +330,7 @@ func (r *serverResource) Schema(_ context.Context, _ resource.SchemaRequest, res Description: "Delete the volume during the termination of the server. Only allowed when `source_type` is `image`.", Optional: true, Computed: true, + Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{ boolplanmodifier.RequiresReplace(), },