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

RDS - error deleting, instance not found #12900

Closed
michalschott opened this issue Apr 20, 2020 · 3 comments · Fixed by #15942
Closed

RDS - error deleting, instance not found #12900

michalschott opened this issue Apr 20, 2020 · 3 comments · Fixed by #15942
Assignees
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.
Milestone

Comments

@michalschott
Copy link
Contributor

michalschott commented Apr 20, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.11.14 / probably not terraform related itself

Affected Resource(s)

  • aws_db_instance

Terraform Configuration Files

resource "aws_db_instance" "postgres_nsg" {
...
snapshot_identifier = "${lookup(var.config_nsg, "snapshot_identifier", "")}"
deletion_protection = true
...
  lifecycle {
    create_before_destroy = true
  }
}

Expected Behavior

If instance does not exist, it should be removed from state. It looks like

* ErrCodeDBInstanceNotFoundFault "DBInstanceNotFound"
DBInstanceIdentifier doesn't refer to an existing DB instance.

is not handled at all, ref

Actual Behavior

	* aws_db_instance.postgres (destroy): 2 errors occurred:
	* aws_db_instance.postgres (deposed #1): 1 error occurred:
	* aws_db_instance.postgres (deposed #1): error deleting Database Instance "XXX": DBInstanceNotFound: DBInstance XXX not found.
	status code: 404, request id: 90c00e13-5a4a-40f6-a52f-d512c7e07035

Steps to Reproduce

  1. apply RDS_instance with snapshot identifier
  2. change source snapshot, deletion of old instance should fail
  3. remove old instance using GUI/aws cli
  4. run terraform apply, resource will be still as marked as deposed and TF will keep erroring.
@ghost ghost added the service/rds Issues and PRs that pertain to the rds service. label Apr 20, 2020
@bflad bflad added the needs-triage Waiting for first response or review from a maintainer. label Apr 20, 2020
@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 6, 2020
@bflad bflad self-assigned this Oct 30, 2020
bflad added a commit that referenced this issue Oct 30, 2020
…tion

Reference: #12900

Unfortunately testing this scenario is complicated in the Terraform Plugin SDK acceptance testing framework as refresh before deletion is standard behavior and the error gets caught in the Read function (e.g. disappears testing). In the future, we may propose to write a standard way for converting AWS Go SDK errors with specific error codes and messages to the Terraform Plugin SDK resource.NotFoundError, which we could then use static analysis against in the Read/Delete/CheckDestroy functions to ensure its always handled. For now though, this is a targeted fix for a community reported situation.
bflad added a commit that referenced this issue Nov 11, 2020
…tion (#15942)

Reference: #12900

Unfortunately testing this scenario is complicated in the Terraform Plugin SDK acceptance testing framework as refresh before deletion is standard behavior and the error gets caught in the Read function (e.g. disappears testing). In the future, we may propose to write a standard way for converting AWS Go SDK errors with specific error codes and messages to the Terraform Plugin SDK resource.NotFoundError, which we could then use static analysis against in the Read/Delete/CheckDestroy functions to ensure its always handled. For now though, this is a targeted fix for a community reported situation.
@bflad bflad added this to the v3.15.0 milestone Nov 11, 2020
@bflad
Copy link
Contributor

bflad commented Nov 11, 2020

The fix for this has been merged and will release with version 3.15.0 of the Terraform AWS Provider, later this week. 👍

@ghost
Copy link

ghost commented Nov 12, 2020

This has been released in version 3.15.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 for triage. Thanks!

@ghost
Copy link

ghost commented Dec 12, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
2 participants