Skip to content

Conversation

@tobias-schuemann
Copy link

Description

Closes #44911

This PR fixes a bug where adding or modifying serverless_v2_scaling_configuration on an existing
DocumentDB cluster forced a destructive cluster replacement instead of performing an in-place update.

Root Cause

The resource had a CustomizeDiff function that forced replacement (ForceNew) whenever the serverless
configuration block was added or removed. However, the AWS ModifyDBCluster API supports in-place updates
for this configuration.

Solution

  • Removed the CustomizeDiff block that was forcing replacement
  • Added DiffSuppressFunc to handle AWS's behavior where the configuration persists even when removed
    from Terraform code
  • Follows the established pattern from aws_rds_cluster for the same serverless configuration

Changes

  • cluster.go: Removed CustomizeDiff, added DiffSuppressFunc at block and attribute levels
  • cluster_test.go: Added comprehensive tests for add/modify/remove scenarios
  • Documentation: Updated to reflect persistence behavior
  • Changelog: Added bug fix entry

User Impact

After this change, users can:

  • Add serverless_v2_scaling_configuration to existing clusters (in-place update)
  • Modify min_capacity and max_capacity values (in-place update)
  • Remove the configuration block from code without perpetual drift warnings
  • The configuration remains active in AWS (as documented)

Output from Acceptance Testing

make testacc TESTS=TestAccDocDBCluster_serverless PKG=docdb
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 main 🌿...
TF_ACC=1 go1.24.10 test ./internal/service/docdb/... -v -count 1 -parallel 20 -run='TestAccDocDBCluster_serverless' -timeout 360m -vet=off
2025/11/13 00:11:37 Creating Terraform AWS Provider (SDKv2-style)...
2025/11/13 00:11:37 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccDocDBCluster_serverless
=== PAUSE TestAccDocDBCluster_serverless
=== RUN TestAccDocDBCluster_serverlessAddToExisting
=== PAUSE TestAccDocDBCluster_serverlessAddToExisting
=== CONT TestAccDocDBCluster_serverless
=== CONT TestAccDocDBCluster_serverlessAddToExisting
--- PASS: TestAccDocDBCluster_serverlessAddToExisting (135.21s)
--- PASS: TestAccDocDBCluster_serverless (155.34s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/docdb 160.331s

…ing_configuration

  without replacement

  Fixes hashicorp#44911

  Changes:
  - Removed CustomizeDiff that forced cluster replacement
  - Added DiffSuppressFunc to handle AWS persistence behavior
  - Follows established RDS Aurora pattern
  - Added comprehensive acceptance tests
  - Updated documentation

  The fix allows users to:
  - Add serverless_v2_scaling_configuration to existing clusters (in-place)
  - Modify min/max capacity values (in-place)
  - Remove config block without perpetual drift warnings
@tobias-schuemann tobias-schuemann requested a review from a team as a code owner November 12, 2025 23:37
@github-actions
Copy link
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/docdb Issues and PRs that pertain to the docdb service. size/M Managed by automation to categorize the size of a PR. labels Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Introduces or discusses updates to documentation. needs-triage Waiting for first response or review from a maintainer. service/docdb Issues and PRs that pertain to the docdb service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docdb aws_docdb_cluster serverless_v2_scaling_configuration leads to cluster delete and recreate

1 participant