Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_rds_cluster_instance: fix destroy error when cluster instance is in a read replica #40409

Merged
merged 6 commits into from
Dec 4, 2024

Conversation

johnsonaj
Copy link
Contributor

@johnsonaj johnsonaj commented Dec 3, 2024

Description

When a aws_rds_cluster_instance is a part of aws_rds_cluster destroying failing with the following error:

Error: deleting RDS Cluster Instance (tf-acc-test-5080916373612377726-replica): operation error RDS: DeleteDBInstance, https response error StatusCode: 400, RequestID: d1fbb4b7-0822-40a1-b591-bf858b2a5ba5, InvalidDBClusterStateFault: Cannot delete the last instance of the read replica DB cluster. Promote the DB cluster to a standalone DB cluster in order to delete it.

This adds a force_destroy virtual attribute that will allow practitioners to destroy instances that are a part of a replica cluster. This process promotes the cluster to a standalone cluster so that the instance can be deleted.

reproduction in test

% make testacc TESTARGS='-run=TestAccRDSClusterInstance_Replica_basic' PKG=rds

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/rds/... -v -count 1 -parallel 20  -run=TestAccRDSClusterInstance_ReplicationSourceIdentifier_basic -timeout 360m
2024/12/03 10:06:30 Initializing Terraform AWS Provider...
=== RUN   TestAccRDSClusterInstance_Replica_basic
=== PAUSE TestAccRDSClusterInstance_Replica_basic
=== CONT  TestAccRDSClusterInstance_Replica_basic
    cluster_instance_test.go:966: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: deleting RDS Cluster Instance (tf-acc-test-5080916373612377726-replica): operation error RDS: DeleteDBInstance, https response error StatusCode: 400, RequestID: d1fbb4b7-0822-40a1-b591-bf858b2a5ba5, InvalidDBClusterStateFault: Cannot delete the last instance of the read replica DB cluster. Promote the DB cluster to a standalone DB cluster in order to delete it.

--- FAIL: TestAccRDSClusterInstance_Replica_basic (1642.68s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/rds	1649.528s
FAIL
make: *** [testacc] Error 1

Relations

Closes #6749

References

Output from Acceptance Testing

% make testacc TESTARGS='-run=TestAccRDSClusterInstance_Replica_basic' PKG=rds

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/rds/... -v -count 1 -parallel 20  -run=TestAccRDSClusterInstance_Replica_basic -timeout 360m
2024/12/03 11:21:32 Initializing Terraform AWS Provider...
=== RUN   TestAccRDSClusterInstance_Replica_basic
=== PAUSE TestAccRDSClusterInstance_Replica_basic
=== CONT  TestAccRDSClusterInstance_Replica_basic
--- PASS: TestAccRDSClusterInstance_Replica_basic (3360.45s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	3367.228s
% make testacc TESTARGS='-run=TestAccRDSClusterInstance_' PKG=rds

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/rds/... -v -count 1 -parallel 20  -run=TestAccRDSClusterInstance_ -timeout 360m
2024/12/03 12:31:44 Initializing Terraform AWS Provider...
--- PASS: TestAccRDSClusterInstance_PerformanceInsightsKMSKeyID_auroraPostgresql (825.47s)
--- PASS: TestAccRDSClusterInstance_PerformanceInsightsEnabled_auroraPostgresql (860.38s)
--- PASS: TestAccRDSClusterInstance_PerformanceInsightsKMSKeyIDAuroraPostgresql_defaultKeyToCustomKey (912.25s)
--- PASS: TestAccRDSClusterInstance_identifierPrefix (943.94s)
--- PASS: TestAccRDSClusterInstance_MonitoringRoleARN_enabledToDisabled (1215.05s)
--- PASS: TestAccRDSClusterInstance_identifierGenerated (1221.73s)
--- PASS: TestAccRDSClusterInstance_isAlreadyBeingDeleted (1236.36s)
--- PASS: TestAccRDSClusterInstance_PerformanceInsightsKMSKeyID_auroraMySQL1 (1237.45s)
--- PASS: TestAccRDSClusterInstance_tags (1265.27s)
--- PASS: TestAccRDSClusterInstance_PerformanceInsightsEnabled_auroraMySQL1 (1287.38s)
--- PASS: TestAccRDSClusterInstance_az (1294.98s)
--- PASS: TestAccRDSClusterInstance_basic (1295.43s)
--- PASS: TestAccRDSClusterInstance_MonitoringRoleARN_removedToEnabled (1302.95s)
--- PASS: TestAccRDSClusterInstance_copyTagsToSnapshot (1316.12s)
--- PASS: TestAccRDSClusterInstance_PerformanceInsightsKMSKeyIDAuroraMySQL1_defaultKeyToCustomKey (1321.27s)
--- PASS: TestAccRDSClusterInstance_MonitoringRoleARN_enabledToRemoved (1366.72s)
--- PASS: TestAccRDSClusterInstance_publiclyAccessible (1452.71s)
--- PASS: TestAccRDSClusterInstance_performanceInsightsRetentionPeriod (1541.29s)
--- PASS: TestAccRDSClusterInstance_monitoringInterval (1812.50s)
--- PASS: TestAccRDSClusterInstance_caCertificateIdentifier (1254.09s)
--- PASS: TestAccRDSClusterInstance_kmsKey (1392.53s)
--- PASS: TestAccRDSClusterInstance_disappears (1427.06s)
--- PASS: TestAccRDSClusterInstance_Replica_basic (3121.58s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	3128.253s

Copy link

github-actions bot commented Dec 3, 2024

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/rds Issues and PRs that pertain to the rds service. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. labels Dec 3, 2024
@johnsonaj johnsonaj marked this pull request as ready for review December 3, 2024 22:00
@johnsonaj johnsonaj requested a review from a team as a code owner December 3, 2024 22:00
@ewbankkit ewbankkit self-assigned this Dec 4, 2024
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccRDSClusterInstance_Replica_basic\|TestAccRDSClusterInstance_basic' PKG=rds
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/rds/... -v -count 1 -parallel 20  -run=TestAccRDSClusterInstance_Replica_basic\|TestAccRDSClusterInstance_basic -timeout 360m
2024/12/04 08:40:41 Initializing Terraform AWS Provider...
=== RUN   TestAccRDSClusterInstance_basic
=== PAUSE TestAccRDSClusterInstance_basic
=== RUN   TestAccRDSClusterInstance_Replica_basic
=== PAUSE TestAccRDSClusterInstance_Replica_basic
=== CONT  TestAccRDSClusterInstance_basic
=== CONT  TestAccRDSClusterInstance_Replica_basic
--- PASS: TestAccRDSClusterInstance_basic (1282.68s)
--- PASS: TestAccRDSClusterInstance_Replica_basic (3219.67s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	3224.927s

@johnsonaj johnsonaj merged commit df9c839 into main Dec 4, 2024
54 checks passed
@johnsonaj johnsonaj deleted the f-rds_instance_cluster_replica_delete branch December 4, 2024 15:26
@github-actions github-actions bot added this to the v5.80.0 milestone Dec 4, 2024
terraform-aws-provider bot pushed a commit that referenced this pull request Dec 4, 2024
Copy link

github-actions bot commented Dec 4, 2024

This functionality has been released in v5.80.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/rds Issues and PRs that pertain to the rds service. 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.

Cannot destroy an Aurora RDS cluster when it was built with a replication_source_identifier value
2 participants