Skip to content

[AV-132344] Fix id= alias and add import docs for cluster deletion protection#622

Merged
Talina06 merged 2 commits into
mainfrom
AV-132344_fix_docs
May 29, 2026
Merged

[AV-132344] Fix id= alias and add import docs for cluster deletion protection#622
Talina06 merged 2 commits into
mainfrom
AV-132344_fix_docs

Conversation

@Talina06
Copy link
Copy Markdown
Member

@Talina06 Talina06 commented May 29, 2026

Jira

  • AV-132344

Description

Problem

couchbase-capella_cluster_deletion_protection uses cluster_id as its Terraform primary key
rather than the conventional id. When a user ran:

terraform import 'couchbase-capella_cluster_deletion_protection.my_resource' \
  'id=<cluster_id>,project_id=<project_id>,organization_id=<organization_id>'

the import failed because ImportStatePassthroughID stored the raw string into the cluster_id
path, and the downstream splitImportString parser looked up id in the importIds table --
which maps to the generic Id attribute, not ClusterId. The parsed map therefore lacked
cluster_id and checkKeysAndValues rejected it.

Changes

  • cluster_deletion_protection.go -- Added normalizeDeletionProtectionImportID, called
    from ImportState before delegating to ImportStatePassthroughID. It rewrites an exact
    id=<value> key to cluster_id=<value>, leaving all other keys (including organization_id
    and project_id, which contain "id" as a substring) untouched.

  • cluster_deletion_protection_test.go -- Unit tests covering the normalization: leading
    id=, mid-string id=, already-correct cluster_id=, substring-safe keys, and empty input.

  • cluster_deletion_protection_acceptance_test.go -- New acceptance test
    TestAccClusterDeletionProtectionResourceImportWithIdAlias that performs a full import cycle
    using the id= form and verifies state is reconciled correctly.

  • examples/deletion_protection/README.md -- Added an IMPORT section with the correct
    terraform import syntax, required key table, a sample command, and a note that id= is
    accepted as an alias for cluster_id=.

Testing

  • Unit tests: go test ./internal/resources/ -run Test_normalizeDeletionProtectionImportID
  • Acceptance test: TestAccClusterDeletionProtectionResourceImportWithIdAlias

Type of Change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • This change updates the ci/cd workflow.
  • Documentation fix/enhancement.

Manual Testing Approach

How was this change tested and do you have evidence? (REQUIRED: Select at least 1)

  • Manually tested
  • Unit tested
  • Acceptance tested
  • Unable to test / will not test (Please provide comments in section below)

Testing

Testing

Further comments

@Talina06 Talina06 requested a review from a team as a code owner May 29, 2026 05:03
Copilot AI review requested due to automatic review settings May 29, 2026 05:03
@github-actions
Copy link
Copy Markdown

No PR template selections were detected. Please make sure to fill out the PR template properly by selecting the appropriate checkboxes.

@factory-droid
Copy link
Copy Markdown
Contributor

factory-droid Bot commented May 29, 2026

Droid finished @Talina06's task —— View job


nimiyajoseph
nimiyajoseph previously approved these changes May 29, 2026
Copy link
Copy Markdown
Contributor

@nimiyajoseph nimiyajoseph left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ImportState input so id= is converted to cluster_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.

Comment thread acceptance_tests/cluster_deletion_protection_acceptance_test.go
Copy link
Copy Markdown
Contributor

@factory-droid factory-droid Bot left a comment

Choose a reason for hiding this comment

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

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.

@Talina06 Talina06 added the bug Something isn't working label May 29, 2026
@Talina06 Talina06 changed the title [AV-132344] Fix docs for Cluster Deletion Protection [AV-132344] Fix id= alias and add import docs for cluster deletion protection May 29, 2026
Copy link
Copy Markdown

@saiakhil2012 saiakhil2012 left a comment

Choose a reason for hiding this comment

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

LGTM

@Talina06 Talina06 merged commit 8583aa0 into main May 29, 2026
12 checks passed
@Talina06 Talina06 deleted the AV-132344_fix_docs branch May 29, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs-triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants