Skip to content

cloudstack_service_offering_fixed/_constrained/_unconstrained do not support terraform import #358

Open

Description

@weizhouapache

The new Plugin Framework resources cloudstack_service_offering_fixed, cloudstack_service_offering_constrained and cloudstack_service_offering_unconstrained do not implement ImportState. Existing service offerings cannot be imported into them. The only importable resource is the deprecated cloudstack_service_offering, which prints a deprecation warning telling users to move to the new resources.

Users cannot follow that guidance for offerings that already exist, so migrating to the new resources means destroying and recreating the offerings.

Steps to reproduce

  1. Use provider cloudstack/cloudstack version 0.7.0, with Terraform 1.16.7.
  2. Create a fixed service offering in CloudStack (for example test-fixed, 1 CPU, 500 MHz, 512 MB).
  3. Add the resource:
    resource "cloudstack_service_offering_fixed" "test_fixed" {
      name         = "test-fixed"
      display_text = "test-fixed"
      cpu_number   = 1
      cpu_speed    = 500
      memory       = 512
    }
  4. Run:
    terraform import cloudstack_service_offering_fixed.test_fixed <offering-uuid>
    
    Importing inside a module with for_each gives the same result:
    terraform import 'module.compute_offerings["test-fixed"].cloudstack_service_offering_fixed.compute_offering' <offering-uuid>
    
    An import {} block behaves the same way.

Actual result

Error: Resource Import Not Implemented
This resource does not support import. Please contact the provider developer
for additional information.

Expected result

The import succeeds, as it does for cloudstack_service_offering, and terraform plan shows no changes once the config matches the offering.

Analysis

In v0.7.0, cloudstack/resource_cloudstack_service_offering.go (SDKv2) sets Importer: &schema.ResourceImporter{...}. The new resources (service_offering_fixed_resource.go and the _constrained and _unconstrained equivalents) implement Schema, Create, Read, Update, Delete, Configure and Metadata, but not resource.ResourceWithImportState. A minimal fix would be to add ImportState, passing the ID through to id, to all three resources. Read is already implemented and works once the ID is in state.

Workaround

Import with the deprecated cloudstack_service_offering, then retype the state entry to the new resource type by editing the state JSON. The entry must keep only attributes that exist in the new schema. After that, terraform plan shows no changes, with one gotcha: if the offering has dynamic_scaling_enabled = true, it must be set in config, because the new resource defaults it to false and plans a replacement otherwise. This is a fragile workaround and not a real fix.

Environment

  • Provider: cloudstack/cloudstack 0.7.0
  • Terraform: 1.16.7
  • CloudStack: 4.22

Activity

  1. dheeraj12347 commented on Oct 28, 2026

    @dheeraj12347
    Contributor

    Hi @weizhouapache
    I've implemented ResourceWithImportState for all three service-offering resources and added import-verification steps to their acceptance tests.

    The local test suite passes (go test ./cloudstack and go test ./...). I don't currently have access to a configured CloudStack environment, so live acceptance testing remains outstanding.

    I've opened PR: #359

    Feedback and review would be appreciated.

  2. weizhouapache commented on Oct 28, 2026

    @weizhouapache
    MemberAuthor

    2. Hi @weizhouapache
    I've implemented ResourceWithImportState for all three service-offering resources and added import-verification steps to their acceptance tests.
    The local test suite passes (go test ./cloudstack and go test ./...). I don't currently have access to a configured CloudStack environment, so live acceptance testing remains outstanding.
    I've opened PR: #359
    Feedback and review would be appreciated.

    great, thanks @dheeraj12347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions