Add terraform import support for several cloudstack resources#305
Draft
Pearl1594 wants to merge 1 commit into
Draft
Add terraform import support for several cloudstack resources#305Pearl1594 wants to merge 1 commit into
Pearl1594 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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
Importersupport 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") | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.