From eec77263ed3b85a557e064fcf674a29267ac24df Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Fri, 7 Aug 2026 10:44:04 -0700 Subject: [PATCH 1/6] Adding zoneid and tags --- .../service_offering_constrained_resource.go | 1 + cloudstack/service_offering_fixed_resource.go | 1 + cloudstack/service_offering_models.go | 2 ++ cloudstack/service_offering_schema.go | 9 ++++++ ...service_offering_unconstrained_resource.go | 1 + cloudstack/service_offering_util.go | 32 +++++++++++++++---- 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/cloudstack/service_offering_constrained_resource.go b/cloudstack/service_offering_constrained_resource.go index 92c80779..ca827366 100644 --- a/cloudstack/service_offering_constrained_resource.go +++ b/cloudstack/service_offering_constrained_resource.go @@ -111,6 +111,7 @@ func (r *serviceOfferingConstrainedResource) Create(ctx context.Context, req res // common params params := r.client.ServiceOffering.NewCreateServiceOfferingParams(plan.DisplayText.ValueString(), plan.Name.ValueString()) plan.commonCreateParams(ctx, params) + plan.applyLegacyTagsAlias(params) planDiskQosHypervisor.commonCreateParams(ctx, params) planDiskOffering.commonCreateParams(ctx, params) planDiskQosStorage.commonCreateParams(ctx, params) diff --git a/cloudstack/service_offering_fixed_resource.go b/cloudstack/service_offering_fixed_resource.go index 6b500fd2..57428121 100644 --- a/cloudstack/service_offering_fixed_resource.go +++ b/cloudstack/service_offering_fixed_resource.go @@ -96,6 +96,7 @@ func (r *serviceOfferingFixedResource) Create(ctx context.Context, req resource. // cloudstack params params := r.client.ServiceOffering.NewCreateServiceOfferingParams(plan.DisplayText.ValueString(), plan.Name.ValueString()) plan.commonCreateParams(ctx, params) + plan.applyLegacyTagsAlias(params) planDiskQosHypervisor.commonCreateParams(ctx, params) planDiskOffering.commonCreateParams(ctx, params) planDiskQosStorage.commonCreateParams(ctx, params) diff --git a/cloudstack/service_offering_models.go b/cloudstack/service_offering_models.go index a93ffa48..183849a1 100644 --- a/cloudstack/service_offering_models.go +++ b/cloudstack/service_offering_models.go @@ -54,6 +54,8 @@ type serviceOfferingCommonResourceModel struct { Name types.String `tfsdk:"name"` NetworkRate types.Int32 `tfsdk:"network_rate"` OfferHa types.Bool `tfsdk:"offer_ha"` + Tags types.String `tfsdk:"tags"` + ZoneId types.Set `tfsdk:"zone_id"` ZoneIds types.Set `tfsdk:"zone_ids"` ServiceOfferingDiskQosHypervisor types.Object `tfsdk:"disk_hypervisor"` ServiceOfferingDiskOffering types.Object `tfsdk:"disk_offering"` diff --git a/cloudstack/service_offering_schema.go b/cloudstack/service_offering_schema.go index 9586d513..7e68b4f6 100644 --- a/cloudstack/service_offering_schema.go +++ b/cloudstack/service_offering_schema.go @@ -108,6 +108,15 @@ func serviceOfferingMergeCommonSchema(s1 map[string]schema.Attribute) map[string }, Default: booldefault.StaticBool(false), }, + "tags": schema.StringAttribute{ + Description: "Legacy alias for storage tags", + Optional: true, + }, + "zone_id": schema.SetAttribute{ + Description: "Legacy alias for zone_ids", + Optional: true, + ElementType: types.StringType, + }, "zone_ids": schema.SetAttribute{ Description: "The ID of the zone(s)", Optional: true, diff --git a/cloudstack/service_offering_unconstrained_resource.go b/cloudstack/service_offering_unconstrained_resource.go index 98b937cd..af935a4d 100644 --- a/cloudstack/service_offering_unconstrained_resource.go +++ b/cloudstack/service_offering_unconstrained_resource.go @@ -73,6 +73,7 @@ func (r *serviceOfferingUnconstrainedResource) Create(ctx context.Context, req r // cloudstack params params := r.client.ServiceOffering.NewCreateServiceOfferingParams(plan.DisplayText.ValueString(), plan.Name.ValueString()) plan.commonCreateParams(ctx, params) + plan.applyLegacyTagsAlias(params) planDiskQosHypervisor.commonCreateParams(ctx, params) planDiskOffering.commonCreateParams(ctx, params) planDiskQosStorage.commonCreateParams(ctx, params) diff --git a/cloudstack/service_offering_util.go b/cloudstack/service_offering_util.go index 666e0fce..d242ad01 100644 --- a/cloudstack/service_offering_util.go +++ b/cloudstack/service_offering_util.go @@ -42,7 +42,9 @@ func (state *serviceOfferingCommonResourceModel) commonUpdate(ctx context.Contex state.Name = types.StringValue(cs.Name) } if cs.Zoneid != "" { - state.ZoneIds, _ = types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) + z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) + state.ZoneIds = z + state.ZoneId = z } } @@ -59,8 +61,12 @@ func (plan *serviceOfferingCommonResourceModel) commonUpdateParams(ctx context.C if !plan.Name.IsNull() { p.SetName(plan.Name.ValueString()) } - if !plan.ZoneIds.IsNull() && len(plan.ZoneIds.Elements()) > 0 { - p.SetZoneid(plan.ZoneIds.String()) + zoneIDs := plan.ZoneIds + if zoneIDs.IsNull() || len(zoneIDs.Elements()) == 0 { + zoneIDs = plan.ZoneId + } + if !zoneIDs.IsNull() && len(zoneIDs.Elements()) > 0 { + p.SetZoneid(zoneIDs.String()) } else { p.SetZoneid("all") } @@ -100,7 +106,9 @@ func (state *serviceOfferingCommonResourceModel) commonRead(ctx context.Context, state.NetworkRate = types.Int32Value(int32(cs.Networkrate)) } if cs.Zoneid != "" { - state.ZoneIds, _ = types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) + z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) + state.ZoneIds = z + state.ZoneId = z } state.DynamicScalingEnabled = types.BoolValue(cs.Dynamicscalingenabled) @@ -205,9 +213,13 @@ func (plan *serviceOfferingCommonResourceModel) commonCreateParams(ctx context.C if !plan.OfferHa.IsNull() { p.SetOfferha(plan.OfferHa.ValueBool()) } - if !plan.ZoneIds.IsNull() { - zoneIds := make([]string, len(plan.ZoneIds.Elements())) - plan.ZoneIds.ElementsAs(ctx, &zoneIds, false) + zoneIDs := plan.ZoneIds + if zoneIDs.IsNull() || len(zoneIDs.Elements()) == 0 { + zoneIDs = plan.ZoneId + } + if !zoneIDs.IsNull() { + zoneIds := make([]string, len(zoneIDs.Elements())) + zoneIDs.ElementsAs(ctx, &zoneIds, false) p.SetZoneid(zoneIds) } @@ -262,6 +274,12 @@ func (plan *ServiceOfferingDiskOffering) commonCreateParams(ctx context.Context, } +func (plan *serviceOfferingCommonResourceModel) applyLegacyTagsAlias(p *cloudstack.CreateServiceOfferingParams) { + if !plan.Tags.IsNull() { + p.SetTags(plan.Tags.ValueString()) + } +} + func (plan *ServiceOfferingDiskQosStorage) commonCreateParams(ctx context.Context, p *cloudstack.CreateServiceOfferingParams) *cloudstack.CreateServiceOfferingParams { if !plan.CustomizedIops.IsNull() { p.SetCustomizediops(plan.CustomizedIops.ValueBool()) From 77d86c502ef08b93d8cf8e75659e9395f10b1218 Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Fri, 7 Aug 2026 11:56:44 -0700 Subject: [PATCH 2/6] updates --- cloudstack/service_offering_util.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cloudstack/service_offering_util.go b/cloudstack/service_offering_util.go index d242ad01..19ed1da9 100644 --- a/cloudstack/service_offering_util.go +++ b/cloudstack/service_offering_util.go @@ -41,10 +41,12 @@ func (state *serviceOfferingCommonResourceModel) commonUpdate(ctx context.Contex if cs.Name != "" { state.Name = types.StringValue(cs.Name) } - if cs.Zoneid != "" { + if cs.Zoneid != "" && cs.Zoneid != "all" { z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) state.ZoneIds = z - state.ZoneId = z + } else { + z, _ := types.SetValueFrom(ctx, types.StringType, []string{}) + state.ZoneIds = z } } @@ -105,10 +107,12 @@ func (state *serviceOfferingCommonResourceModel) commonRead(ctx context.Context, if cs.Networkrate > 0 { state.NetworkRate = types.Int32Value(int32(cs.Networkrate)) } - if cs.Zoneid != "" { + if cs.Zoneid != "" && cs.Zoneid != "all" { z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) state.ZoneIds = z - state.ZoneId = z + } else { + z, _ := types.SetValueFrom(ctx, types.StringType, []string{}) + state.ZoneIds = z } state.DynamicScalingEnabled = types.BoolValue(cs.Dynamicscalingenabled) From ffbdae6a3f3eada2f3db320aac7be1a42e6ad18e Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Fri, 7 Aug 2026 12:33:16 -0700 Subject: [PATCH 3/6] updates --- cloudstack/service_offering_util.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cloudstack/service_offering_util.go b/cloudstack/service_offering_util.go index 19ed1da9..7a729dc1 100644 --- a/cloudstack/service_offering_util.go +++ b/cloudstack/service_offering_util.go @@ -45,8 +45,7 @@ func (state *serviceOfferingCommonResourceModel) commonUpdate(ctx context.Contex z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) state.ZoneIds = z } else { - z, _ := types.SetValueFrom(ctx, types.StringType, []string{}) - state.ZoneIds = z + state.ZoneIds = types.SetNull(types.StringType) } } @@ -111,8 +110,7 @@ func (state *serviceOfferingCommonResourceModel) commonRead(ctx context.Context, z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) state.ZoneIds = z } else { - z, _ := types.SetValueFrom(ctx, types.StringType, []string{}) - state.ZoneIds = z + state.ZoneIds = types.SetNull(types.StringType) } state.DynamicScalingEnabled = types.BoolValue(cs.Dynamicscalingenabled) From dea61d8359bc2b18901ef8f472eb5ddd55402160 Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Fri, 7 Aug 2026 12:54:06 -0700 Subject: [PATCH 4/6] updates --- cloudstack/service_offering_util.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cloudstack/service_offering_util.go b/cloudstack/service_offering_util.go index 7a729dc1..5251c3d2 100644 --- a/cloudstack/service_offering_util.go +++ b/cloudstack/service_offering_util.go @@ -44,9 +44,8 @@ func (state *serviceOfferingCommonResourceModel) commonUpdate(ctx context.Contex if cs.Zoneid != "" && cs.Zoneid != "all" { z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) state.ZoneIds = z - } else { - state.ZoneIds = types.SetNull(types.StringType) } + // else: preserve prior state value (null or []) — both mean "all zones" } func (plan *serviceOfferingCommonResourceModel) commonUpdateParams(ctx context.Context, p *cloudstack.UpdateServiceOfferingParams) *cloudstack.UpdateServiceOfferingParams { @@ -109,9 +108,8 @@ func (state *serviceOfferingCommonResourceModel) commonRead(ctx context.Context, if cs.Zoneid != "" && cs.Zoneid != "all" { z, _ := types.SetValueFrom(ctx, types.StringType, strings.Split(cs.Zoneid, ",")) state.ZoneIds = z - } else { - state.ZoneIds = types.SetNull(types.StringType) } + // else: preserve prior state value (null or []) — both mean "all zones" state.DynamicScalingEnabled = types.BoolValue(cs.Dynamicscalingenabled) state.IsVolatile = types.BoolValue(cs.Isvolatile) From 6fb7747be9ac06601d1eb74b94a6f25486d5513a Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:39:05 -0700 Subject: [PATCH 5/6] adding go cache to gitignore file --- cloudstack/service_offering_constrained_resource.go | 2 +- cloudstack/service_offering_fixed_resource.go | 2 +- cloudstack/service_offering_models.go | 1 - cloudstack/service_offering_schema.go | 7 +------ cloudstack/service_offering_unconstrained_resource.go | 2 +- cloudstack/service_offering_util.go | 8 +------- 6 files changed, 5 insertions(+), 17 deletions(-) diff --git a/cloudstack/service_offering_constrained_resource.go b/cloudstack/service_offering_constrained_resource.go index ca827366..d20c2efd 100644 --- a/cloudstack/service_offering_constrained_resource.go +++ b/cloudstack/service_offering_constrained_resource.go @@ -111,7 +111,7 @@ func (r *serviceOfferingConstrainedResource) Create(ctx context.Context, req res // common params params := r.client.ServiceOffering.NewCreateServiceOfferingParams(plan.DisplayText.ValueString(), plan.Name.ValueString()) plan.commonCreateParams(ctx, params) - plan.applyLegacyTagsAlias(params) + plan.applyTags(params) planDiskQosHypervisor.commonCreateParams(ctx, params) planDiskOffering.commonCreateParams(ctx, params) planDiskQosStorage.commonCreateParams(ctx, params) diff --git a/cloudstack/service_offering_fixed_resource.go b/cloudstack/service_offering_fixed_resource.go index 57428121..bf08e02c 100644 --- a/cloudstack/service_offering_fixed_resource.go +++ b/cloudstack/service_offering_fixed_resource.go @@ -96,7 +96,7 @@ func (r *serviceOfferingFixedResource) Create(ctx context.Context, req resource. // cloudstack params params := r.client.ServiceOffering.NewCreateServiceOfferingParams(plan.DisplayText.ValueString(), plan.Name.ValueString()) plan.commonCreateParams(ctx, params) - plan.applyLegacyTagsAlias(params) + plan.applyTags(params) planDiskQosHypervisor.commonCreateParams(ctx, params) planDiskOffering.commonCreateParams(ctx, params) planDiskQosStorage.commonCreateParams(ctx, params) diff --git a/cloudstack/service_offering_models.go b/cloudstack/service_offering_models.go index 183849a1..d142b104 100644 --- a/cloudstack/service_offering_models.go +++ b/cloudstack/service_offering_models.go @@ -55,7 +55,6 @@ type serviceOfferingCommonResourceModel struct { NetworkRate types.Int32 `tfsdk:"network_rate"` OfferHa types.Bool `tfsdk:"offer_ha"` Tags types.String `tfsdk:"tags"` - ZoneId types.Set `tfsdk:"zone_id"` ZoneIds types.Set `tfsdk:"zone_ids"` ServiceOfferingDiskQosHypervisor types.Object `tfsdk:"disk_hypervisor"` ServiceOfferingDiskOffering types.Object `tfsdk:"disk_offering"` diff --git a/cloudstack/service_offering_schema.go b/cloudstack/service_offering_schema.go index 7e68b4f6..dc9fdfe0 100644 --- a/cloudstack/service_offering_schema.go +++ b/cloudstack/service_offering_schema.go @@ -109,14 +109,9 @@ func serviceOfferingMergeCommonSchema(s1 map[string]schema.Attribute) map[string Default: booldefault.StaticBool(false), }, "tags": schema.StringAttribute{ - Description: "Legacy alias for storage tags", + Description: "The tags for the service offering", Optional: true, }, - "zone_id": schema.SetAttribute{ - Description: "Legacy alias for zone_ids", - Optional: true, - ElementType: types.StringType, - }, "zone_ids": schema.SetAttribute{ Description: "The ID of the zone(s)", Optional: true, diff --git a/cloudstack/service_offering_unconstrained_resource.go b/cloudstack/service_offering_unconstrained_resource.go index af935a4d..9735603a 100644 --- a/cloudstack/service_offering_unconstrained_resource.go +++ b/cloudstack/service_offering_unconstrained_resource.go @@ -73,7 +73,7 @@ func (r *serviceOfferingUnconstrainedResource) Create(ctx context.Context, req r // cloudstack params params := r.client.ServiceOffering.NewCreateServiceOfferingParams(plan.DisplayText.ValueString(), plan.Name.ValueString()) plan.commonCreateParams(ctx, params) - plan.applyLegacyTagsAlias(params) + plan.applyTags(params) planDiskQosHypervisor.commonCreateParams(ctx, params) planDiskOffering.commonCreateParams(ctx, params) planDiskQosStorage.commonCreateParams(ctx, params) diff --git a/cloudstack/service_offering_util.go b/cloudstack/service_offering_util.go index 5251c3d2..8eef2b2a 100644 --- a/cloudstack/service_offering_util.go +++ b/cloudstack/service_offering_util.go @@ -62,9 +62,6 @@ func (plan *serviceOfferingCommonResourceModel) commonUpdateParams(ctx context.C p.SetName(plan.Name.ValueString()) } zoneIDs := plan.ZoneIds - if zoneIDs.IsNull() || len(zoneIDs.Elements()) == 0 { - zoneIDs = plan.ZoneId - } if !zoneIDs.IsNull() && len(zoneIDs.Elements()) > 0 { p.SetZoneid(zoneIDs.String()) } else { @@ -214,9 +211,6 @@ func (plan *serviceOfferingCommonResourceModel) commonCreateParams(ctx context.C p.SetOfferha(plan.OfferHa.ValueBool()) } zoneIDs := plan.ZoneIds - if zoneIDs.IsNull() || len(zoneIDs.Elements()) == 0 { - zoneIDs = plan.ZoneId - } if !zoneIDs.IsNull() { zoneIds := make([]string, len(zoneIDs.Elements())) zoneIDs.ElementsAs(ctx, &zoneIds, false) @@ -274,7 +268,7 @@ func (plan *ServiceOfferingDiskOffering) commonCreateParams(ctx context.Context, } -func (plan *serviceOfferingCommonResourceModel) applyLegacyTagsAlias(p *cloudstack.CreateServiceOfferingParams) { +func (plan *serviceOfferingCommonResourceModel) applyTags(p *cloudstack.CreateServiceOfferingParams) { if !plan.Tags.IsNull() { p.SetTags(plan.Tags.ValueString()) } From 514872137d49adef96aba5ed2057c9d4a9fa6359 Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Tue, 11 Aug 2026 13:29:01 -0700 Subject: [PATCH 6/6] adding go cache to gitignore file --- cloudstack/service_offering_constrained_resource.go | 5 +++++ cloudstack/service_offering_constrained_resource_test.go | 5 +++++ cloudstack/service_offering_fixed_resource.go | 5 +++++ cloudstack/service_offering_fixed_resource_test.go | 5 +++++ cloudstack/service_offering_unconstrained_resource.go | 5 +++++ .../service_offering_unconstrained_resource_test.go | 5 +++++ cloudstack/service_offering_util.go | 8 ++++++-- 7 files changed, 36 insertions(+), 2 deletions(-) diff --git a/cloudstack/service_offering_constrained_resource.go b/cloudstack/service_offering_constrained_resource.go index d20c2efd..b84c1b5a 100644 --- a/cloudstack/service_offering_constrained_resource.go +++ b/cloudstack/service_offering_constrained_resource.go @@ -25,6 +25,7 @@ import ( "strconv" "github.com/apache/cloudstack-go/v2/cloudstack" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int32planmodifier" @@ -288,6 +289,10 @@ func (r *serviceOfferingConstrainedResource) Delete(ctx context.Context, req res } } +func (r *serviceOfferingConstrainedResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + func (r *serviceOfferingConstrainedResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Add a nil check when handling ProviderData because Terraform // sets that data after it calls the ConfigureProvider RPC. diff --git a/cloudstack/service_offering_constrained_resource_test.go b/cloudstack/service_offering_constrained_resource_test.go index 5368db7b..190fe834 100644 --- a/cloudstack/service_offering_constrained_resource_test.go +++ b/cloudstack/service_offering_constrained_resource_test.go @@ -36,6 +36,11 @@ func TestAccServiceOfferingConstrained(t *testing.T) { resource.TestCheckResourceAttr("cloudstack_service_offering_constrained.constrained1", "name", "constrained1"), ), }, + { + ResourceName: "cloudstack_service_offering_constrained.constrained1", + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccServiceOfferingCustomConstrained1ZoneAll, Check: resource.ComposeTestCheckFunc( diff --git a/cloudstack/service_offering_fixed_resource.go b/cloudstack/service_offering_fixed_resource.go index bf08e02c..c8b001ae 100644 --- a/cloudstack/service_offering_fixed_resource.go +++ b/cloudstack/service_offering_fixed_resource.go @@ -24,6 +24,7 @@ import ( "fmt" "github.com/apache/cloudstack-go/v2/cloudstack" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int32planmodifier" @@ -228,6 +229,10 @@ func (r *serviceOfferingFixedResource) Delete(ctx context.Context, req resource. } } +func (r *serviceOfferingFixedResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + func (r *serviceOfferingFixedResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Add a nil check when handling ProviderData because Terraform // sets that data after it calls the ConfigureProvider RPC. diff --git a/cloudstack/service_offering_fixed_resource_test.go b/cloudstack/service_offering_fixed_resource_test.go index 438740e0..f5d4a30e 100644 --- a/cloudstack/service_offering_fixed_resource_test.go +++ b/cloudstack/service_offering_fixed_resource_test.go @@ -36,6 +36,11 @@ func TestAccServiceOfferingFixed(t *testing.T) { resource.TestCheckResourceAttr("cloudstack_service_offering_fixed.fixed1", "name", "fixed1"), ), }, + { + ResourceName: "cloudstack_service_offering_fixed.fixed1", + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccServiceOfferingFixed2, Check: resource.ComposeTestCheckFunc( diff --git a/cloudstack/service_offering_unconstrained_resource.go b/cloudstack/service_offering_unconstrained_resource.go index 9735603a..bbb89abd 100644 --- a/cloudstack/service_offering_unconstrained_resource.go +++ b/cloudstack/service_offering_unconstrained_resource.go @@ -24,6 +24,7 @@ import ( "fmt" "github.com/apache/cloudstack-go/v2/cloudstack" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -182,6 +183,10 @@ func (r *serviceOfferingUnconstrainedResource) Delete(ctx context.Context, req r } } +func (r *serviceOfferingUnconstrainedResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + func (r *serviceOfferingUnconstrainedResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { if req.ProviderData == nil { return diff --git a/cloudstack/service_offering_unconstrained_resource_test.go b/cloudstack/service_offering_unconstrained_resource_test.go index 5aba779f..79d83cf2 100644 --- a/cloudstack/service_offering_unconstrained_resource_test.go +++ b/cloudstack/service_offering_unconstrained_resource_test.go @@ -36,6 +36,11 @@ func TestAccServiceOfferingUnconstrained(t *testing.T) { resource.TestCheckResourceAttr("cloudstack_service_offering_unconstrained.unconstrained1", "name", "unconstrained1"), ), }, + { + ResourceName: "cloudstack_service_offering_unconstrained.unconstrained1", + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccServiceOfferingUnconstrained2, Check: resource.ComposeTestCheckFunc( diff --git a/cloudstack/service_offering_util.go b/cloudstack/service_offering_util.go index 8eef2b2a..66991b61 100644 --- a/cloudstack/service_offering_util.go +++ b/cloudstack/service_offering_util.go @@ -53,7 +53,9 @@ func (plan *serviceOfferingCommonResourceModel) commonUpdateParams(ctx context.C p.SetDisplaytext(plan.DisplayText.ValueString()) } if !plan.DomainIds.IsNull() { - p.SetDomainid(plan.DomainIds.String()) + domainIDs := make([]string, len(plan.DomainIds.Elements())) + plan.DomainIds.ElementsAs(ctx, &domainIDs, false) + p.SetDomainid(strings.Join(domainIDs, ",")) } if !plan.HostTags.IsNull() { p.SetHosttags(plan.HostTags.ValueString()) @@ -63,7 +65,9 @@ func (plan *serviceOfferingCommonResourceModel) commonUpdateParams(ctx context.C } zoneIDs := plan.ZoneIds if !zoneIDs.IsNull() && len(zoneIDs.Elements()) > 0 { - p.SetZoneid(zoneIDs.String()) + zoneIDSlice := make([]string, len(zoneIDs.Elements())) + zoneIDs.ElementsAs(ctx, &zoneIDSlice, false) + p.SetZoneid(strings.Join(zoneIDSlice, ",")) } else { p.SetZoneid("all") }