Skip to content

Add terraform import support for several cloudstack resources#305

Draft
Pearl1594 wants to merge 1 commit into
mainfrom
add-import-support
Draft

Add terraform import support for several cloudstack resources#305
Pearl1594 wants to merge 1 commit into
mainfrom
add-import-support

Conversation

@Pearl1594

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 22, 2026 20:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds Terraform import support across a set of CloudStack provider resources by wiring in Importer blocks (including project-aware passthrough where needed), introducing a few custom import state resolvers (e.g., for resources that Read-by-name or that need to materialize nested rule sets), and documenting the expected import IDs. It also adds/extends acceptance tests to validate import behavior for several of the updated resources.

Changes:

  • Added Importer support to multiple resources, using either passthrough import or custom import-state functions where an ID-to-name (or ID-to-ruleset) translation is required.
  • Implemented custom import logic for port-forwarding rules and for offerings that are read back by name (service/network offerings).
  • Added import documentation sections and import acceptance tests for several resources.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
website/docs/r/vpn_connection.html.markdown Documents cloudstack_vpn_connection import usage.
website/docs/r/static_nat.html.markdown Documents cloudstack_static_nat import usage, including project-prefixed IDs.
website/docs/r/port_forward.html.markdown Documents cloudstack_port_forward import behavior and managed-rule import semantics.
website/docs/r/loadbalancer_rule.html.markdown Documents cloudstack_loadbalancer_rule import usage and write-only field caveat.
website/docs/r/ipaddress.html.markdown Documents cloudstack_ipaddress import usage, including project-prefixed IDs.
website/docs/r/counter.html.markdown Documents cloudstack_counter import usage.
website/docs/r/condition.html.markdown Documents cloudstack_condition import usage.
website/docs/r/autoscale_vm_profile.html.markdown Documents cloudstack_autoscale_vm_profile import usage.
website/docs/r/autoscale_policy.html.markdown Documents cloudstack_autoscale_policy import usage.
cloudstack/resource_cloudstack_vpn_connection.go Adds passthrough importer for VPN connections.
cloudstack/resource_cloudstack_vpn_connection_test.go Adds acceptance import test for VPN connections.
cloudstack/resource_cloudstack_static_nat.go Enables project-aware passthrough import for static NAT.
cloudstack/resource_cloudstack_static_nat_test.go Adds acceptance import test for static NAT.
cloudstack/resource_cloudstack_service_offering.go Adds importer that resolves offering name from ID before refresh.
cloudstack/resource_cloudstack_service_offering_test.go Adds acceptance import test for service offerings.
cloudstack/resource_cloudstack_port_forward.go Adds custom importer that imports all port forwarding rules for an IP into the forward set and forces managed=true.
cloudstack/resource_cloudstack_port_forward_test.go Adds acceptance import test for port forwards (ignoring managed).
cloudstack/resource_cloudstack_network_offering.go Adds importer that resolves network offering name from ID before refresh.
cloudstack/resource_cloudstack_loadbalancer_rule.go Enables project-aware passthrough import for load balancer rules.
cloudstack/resource_cloudstack_loadbalancer_rule_test.go Adds acceptance import test for load balancer rules (ignoring certificate_id).
cloudstack/resource_cloudstack_ipaddress.go Enables project-aware passthrough import for IP addresses.
cloudstack/resource_cloudstack_ipaddress_test.go Adds acceptance import test for IP addresses.
cloudstack/resource_cloudstack_host.go Adds passthrough importer for hosts.
cloudstack/resource_cloudstack_host_test.go Adds acceptance import test for hosts with appropriate ignore list for write-only/provider-local fields.
cloudstack/resource_cloudstack_counter.go Adds passthrough importer for counters.
cloudstack/resource_cloudstack_condition.go Adds passthrough importer for conditions.
cloudstack/resource_cloudstack_autoscale_vm_profile.go Adds passthrough importer for autoscale VM profiles.
cloudstack/resource_cloudstack_autoscale_vm_profile_test.go Adds import acceptance test but currently skips it unconditionally.
cloudstack/resource_cloudstack_autoscale_vm_group.go Adds passthrough importer for autoscale VM groups.
cloudstack/resource_cloudstack_autoscale_policy.go Adds passthrough importer for autoscale policies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

VPN Connections can be imported using the `id`, e.g.

```shell
$ terraform import cloudstack_vpn_connection.default eb22f91-7454-4107-89f4-36afcdf33021
Counters can be imported using the `id`, e.g.

```shell
$ terraform import cloudstack_counter.default eb22f91-7454-4107-89f4-36afcdf33021
Conditions can be imported using the `id`, e.g.

```shell
$ terraform import cloudstack_condition.default eb22f91-7454-4107-89f4-36afcdf33021
Autoscale VM profiles can be imported using the `id`, e.g.

```shell
$ terraform import cloudstack_autoscale_vm_profile.default eb22f91-7454-4107-89f4-36afcdf33021
Autoscale policies can be imported using the `id`, e.g.

```shell
$ terraform import cloudstack_autoscale_policy.default eb22f91-7454-4107-89f4-36afcdf33021
Comment on lines +88 to +90
func TestAccCloudStackAutoscaleVMProfile_import(t *testing.T) {
t.Skip("Skipping due to bug in cloudstack-go library")

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants