From 7d60e4c8c5fcbd447568565736f485c5e7c83725 Mon Sep 17 00:00:00 2001 From: Marco Sinhoreli Date: Thu, 11 Jun 2026 11:41:08 +0200 Subject: [PATCH] Add import support to autoscale resources Adds a passthrough Importer (id-driven Read, same pattern as affinity_group and disk) to the autoscale chain resources so existing CloudStack autoscale configurations can be adopted with `terraform import` / import blocks: - cloudstack_counter - cloudstack_condition - cloudstack_autoscale_policy - cloudstack_autoscale_vm_profile - cloudstack_autoscale_vm_group Co-Authored-By: Claude Opus 4.8 Signed-off-by: Marco Sinhoreli --- cloudstack/resource_cloudstack_autoscale_policy.go | 3 +++ cloudstack/resource_cloudstack_autoscale_vm_group.go | 3 +++ cloudstack/resource_cloudstack_autoscale_vm_profile.go | 3 +++ cloudstack/resource_cloudstack_condition.go | 3 +++ cloudstack/resource_cloudstack_counter.go | 3 +++ 5 files changed, 15 insertions(+) diff --git a/cloudstack/resource_cloudstack_autoscale_policy.go b/cloudstack/resource_cloudstack_autoscale_policy.go index fe390b5e..9d21d8d1 100644 --- a/cloudstack/resource_cloudstack_autoscale_policy.go +++ b/cloudstack/resource_cloudstack_autoscale_policy.go @@ -34,6 +34,9 @@ func resourceCloudStackAutoScalePolicy() *schema.Resource { Read: resourceCloudStackAutoScalePolicyRead, Update: resourceCloudStackAutoScalePolicyUpdate, Delete: resourceCloudStackAutoScalePolicyDelete, + Importer: &schema.ResourceImporter{ + State: importStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": { diff --git a/cloudstack/resource_cloudstack_autoscale_vm_group.go b/cloudstack/resource_cloudstack_autoscale_vm_group.go index 8d0eb7e6..80ee4d42 100644 --- a/cloudstack/resource_cloudstack_autoscale_vm_group.go +++ b/cloudstack/resource_cloudstack_autoscale_vm_group.go @@ -35,6 +35,9 @@ func resourceCloudStackAutoScaleVMGroup() *schema.Resource { Read: resourceCloudStackAutoScaleVMGroupRead, Update: resourceCloudStackAutoScaleVMGroupUpdate, Delete: resourceCloudStackAutoScaleVMGroupDelete, + Importer: &schema.ResourceImporter{ + State: importStatePassthrough, + }, Schema: map[string]*schema.Schema{ "lbrule_id": { diff --git a/cloudstack/resource_cloudstack_autoscale_vm_profile.go b/cloudstack/resource_cloudstack_autoscale_vm_profile.go index 0032b92a..48c3ffd2 100644 --- a/cloudstack/resource_cloudstack_autoscale_vm_profile.go +++ b/cloudstack/resource_cloudstack_autoscale_vm_profile.go @@ -35,6 +35,9 @@ func resourceCloudStackAutoScaleVMProfile() *schema.Resource { Read: resourceCloudStackAutoScaleVMProfileRead, Update: resourceCloudStackAutoScaleVMProfileUpdate, Delete: resourceCloudStackAutoScaleVMProfileDelete, + Importer: &schema.ResourceImporter{ + State: importStatePassthrough, + }, Schema: map[string]*schema.Schema{ "service_offering": { diff --git a/cloudstack/resource_cloudstack_condition.go b/cloudstack/resource_cloudstack_condition.go index cd74e5cb..d83cbb2b 100644 --- a/cloudstack/resource_cloudstack_condition.go +++ b/cloudstack/resource_cloudstack_condition.go @@ -33,6 +33,9 @@ func resourceCloudStackCondition() *schema.Resource { Read: resourceCloudStackConditionRead, Update: resourceCloudStackConditionUpdate, Delete: resourceCloudStackConditionDelete, + Importer: &schema.ResourceImporter{ + State: importStatePassthrough, + }, Schema: map[string]*schema.Schema{ "counter_id": { diff --git a/cloudstack/resource_cloudstack_counter.go b/cloudstack/resource_cloudstack_counter.go index ddd7e9e4..32cd70d9 100644 --- a/cloudstack/resource_cloudstack_counter.go +++ b/cloudstack/resource_cloudstack_counter.go @@ -32,6 +32,9 @@ func resourceCloudStackCounter() *schema.Resource { Create: resourceCloudStackCounterCreate, Read: resourceCloudStackCounterRead, Delete: resourceCloudStackCounterDelete, + Importer: &schema.ResourceImporter{ + State: importStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": {