resource/aws_docdb_cluster: Allow adding/modifying serverless_v2_scaling_configuration without replacement #45049
+87
−18
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.
Description
Closes #44911
This PR fixes a bug where adding or modifying
serverless_v2_scaling_configurationon an existingDocumentDB cluster forced a destructive cluster replacement instead of performing an in-place update.
Root Cause
The resource had a
CustomizeDifffunction that forced replacement (ForceNew) whenever the serverlessconfiguration block was added or removed. However, the AWS ModifyDBCluster API supports in-place updates
for this configuration.
Solution
CustomizeDiffblock that was forcing replacementDiffSuppressFuncto handle AWS's behavior where the configuration persists even when removedfrom Terraform code
aws_rds_clusterfor the same serverless configurationChanges
CustomizeDiff, addedDiffSuppressFuncat block and attribute levelsUser Impact
After this change, users can:
serverless_v2_scaling_configurationto existing clusters (in-place update)min_capacityandmax_capacityvalues (in-place update)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