[AV-132344] Fix id= alias and add import docs for cluster deletion protection#622
Conversation
|
No PR template selections were detected. Please make sure to fill out the PR template properly by selecting the appropriate checkboxes. |
There was a problem hiding this comment.
Pull request overview
Fixes confusing import behavior for couchbase-capella_cluster_deletion_protection by accepting id=<cluster_uuid> as an alias for cluster_id=<cluster_uuid> during terraform import, and documents the correct import syntax in the example.
Changes:
- Normalizes
ImportStateinput soid=is converted tocluster_id=before schema parsing. - Adds a focused unit test for the import ID normalization helper.
- Documents import syntax (including the
id=alias) in the deletion protection example README and adds an acceptance test covering the alias import path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/resources/cluster_deletion_protection.go | Normalizes import ID to map id= → cluster_id= before passthrough into state. |
| internal/resources/cluster_deletion_protection_test.go | Unit tests for the import ID normalization behavior. |
| examples/deletion_protection/README.md | Adds an IMPORT section documenting required keys and the id= alias. |
| acceptance_tests/cluster_deletion_protection_acceptance_test.go | Adds acceptance coverage verifying import works with the id= alias. |
There was a problem hiding this comment.
I validated all candidates against the full diff and approved one high-confidence issue: the newly added import-alias acceptance test runs in parallel while sharing mutable global cluster state with another parallel test, which can cause flaky failures.
id= alias and add import docs for cluster deletion protection
Jira
Description
Problem
couchbase-capella_cluster_deletion_protectionusescluster_idas its Terraform primary keyrather than the conventional
id. When a user ran:the import failed because
ImportStatePassthroughIDstored the raw string into thecluster_idpath, and the downstream
splitImportStringparser looked upidin theimportIdstable --which maps to the generic
Idattribute, notClusterId. The parsed map therefore lackedcluster_idandcheckKeysAndValuesrejected it.Changes
cluster_deletion_protection.go-- AddednormalizeDeletionProtectionImportID, calledfrom
ImportStatebefore delegating toImportStatePassthroughID. It rewrites an exactid=<value>key tocluster_id=<value>, leaving all other keys (includingorganization_idand
project_id, which contain "id" as a substring) untouched.cluster_deletion_protection_test.go-- Unit tests covering the normalization: leadingid=, mid-stringid=, already-correctcluster_id=, substring-safe keys, and empty input.cluster_deletion_protection_acceptance_test.go-- New acceptance testTestAccClusterDeletionProtectionResourceImportWithIdAliasthat performs a full import cycleusing the
id=form and verifies state is reconciled correctly.examples/deletion_protection/README.md-- Added an IMPORT section with the correctterraform importsyntax, required key table, a sample command, and a note thatid=isaccepted as an alias for
cluster_id=.Testing
go test ./internal/resources/ -run Test_normalizeDeletionProtectionImportIDTestAccClusterDeletionProtectionResourceImportWithIdAliasType of Change
Manual Testing Approach
How was this change tested and do you have evidence? (REQUIRED: Select at least 1)
Testing
Testing
Further comments