Terraform-provider-aws: aws_db_event_subscription deletion is failing with `Error deleting RDS Event Subscription`

Created on 5 Jul 2019  ·  5Comments  ·  Source: hashicorp/terraform-provider-aws

Issue

While trying to delete an existing aws_db_event_subscription, terraform apply is failing with following error.


aws_db_event_subscription.some_name: Still destroying... (ID: some_id, 30s elapsed)
--
  |  
  | Error: Error applying plan:
  |  
  | 1 error occurred:
  | * aws_db_event_subscription.some_name (destroy): 1 error occurred:
  | * aws_db_event_subscription.some_name: Error deleting RDS Event Subscription some_id : Unable to find RDS Event Subscription: []*rds.EventSubscription(nil)
  | 

Terraform plan is showing deletion of RDS subscription event correctly but during the apply phase, it's throwing the above error. Once the terraform apply is failed, all the events are deleted in the actual AWS account, but terraform plan still has the RDS event entries in the state file. As a result, Terraform plan is failing for all the subsequent builds. Below is the plan failure

Error: Error refreshing state: 1 error occurred:
--
  | * aws_db_event_subscription.some_name: aws_db_event_subscription.some_name: Error retrieving RDS Event Subscription some_id : Unable to find RDS Event Subscription: []*rds.EventSubscription(nil)

Steps to reproduce

  • Create a AWS RDS subscription event
  • Try to delete the event and apply the change

Affected Versions

  • Terraform Version: 0.11.14
  • Terraform Aws Provider version: 2.17.0
bug servicrds upstream

Most helpful comment

I just ran into the same issue using version2.19.0 - the destroy removed the event from AWS but left the entry in the statefile:

  • provider.aws: version = "~> 2.19"

Terraform has been successfully initialized!

aws_db_event_subscription.EventSubscriptionAlarmInstance: Refreshing state... (ID: isg-mysql-demo4-eventsubscriptionalarminstance)

Error: Error refreshing state: 1 error(s) occurred:

  • aws_db_event_subscription.EventSubscriptionAlarmInstance: 1 error(s) occurred:

  • aws_db_event_subscription.EventSubscriptionAlarmInstance: aws_db_event_subscription.EventSubscriptionAlarmInstance: error retrieving RDS Event Subscription (isg-mysql-demo4-eventsubscriptionalarminstance): SubscriptionNotFound: Event Subscription isg-mysql-demo4-eventsubscriptionalarminstance not found.
    status code: 404, request id: b8ec0a3f-e84e-4eef-9e6b-adf15bb88d69

Statefile:
"primary": {
"id": "isg-mysql-demo4-eventsubscriptionalarminstance",
"attributes": {
"arn": "arn:aws:rds:us-east-1:############:es:isg-mysql-demo4-eventsubscriptionalarminstance",
"customer_aws_id": "############",
"enabled": "true",
"event_categories.#": "12",
"event_categories.1068999359": "availability",
"event_categories.1072746924": "backup",
"event_categories.1866582008": "restoration",
"event_categories.2890955135": "configuration change",
"event_categories.3037192942": "low storage",
"event_categories.3102116255": "failover",
"event_categories.3209983690": "notification",
"event_categories.3430174804": "read replica",
"event_categories.4081292233": "recovery",
"event_categories.563807169": "failure",
"event_categories.769513765": "deletion",
"event_categories.797243625": "maintenance",
"id": "isg-mysql-demo4-eventsubscriptionalarminstance",
"name": "isg-mysql-demo4-eventsubscriptionalarminstance",
................

All 5 comments

The fix for this has been merged and will be released with version 2.19.0 of the Terraform AWS Provider, likely in two days. 👍

This has been released in version 2.19.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!

I just ran into the same issue using version2.19.0 - the destroy removed the event from AWS but left the entry in the statefile:

  • provider.aws: version = "~> 2.19"

Terraform has been successfully initialized!

aws_db_event_subscription.EventSubscriptionAlarmInstance: Refreshing state... (ID: isg-mysql-demo4-eventsubscriptionalarminstance)

Error: Error refreshing state: 1 error(s) occurred:

  • aws_db_event_subscription.EventSubscriptionAlarmInstance: 1 error(s) occurred:

  • aws_db_event_subscription.EventSubscriptionAlarmInstance: aws_db_event_subscription.EventSubscriptionAlarmInstance: error retrieving RDS Event Subscription (isg-mysql-demo4-eventsubscriptionalarminstance): SubscriptionNotFound: Event Subscription isg-mysql-demo4-eventsubscriptionalarminstance not found.
    status code: 404, request id: b8ec0a3f-e84e-4eef-9e6b-adf15bb88d69

Statefile:
"primary": {
"id": "isg-mysql-demo4-eventsubscriptionalarminstance",
"attributes": {
"arn": "arn:aws:rds:us-east-1:############:es:isg-mysql-demo4-eventsubscriptionalarminstance",
"customer_aws_id": "############",
"enabled": "true",
"event_categories.#": "12",
"event_categories.1068999359": "availability",
"event_categories.1072746924": "backup",
"event_categories.1866582008": "restoration",
"event_categories.2890955135": "configuration change",
"event_categories.3037192942": "low storage",
"event_categories.3102116255": "failover",
"event_categories.3209983690": "notification",
"event_categories.3430174804": "read replica",
"event_categories.4081292233": "recovery",
"event_categories.563807169": "failure",
"event_categories.769513765": "deletion",
"event_categories.797243625": "maintenance",
"id": "isg-mysql-demo4-eventsubscriptionalarminstance",
"name": "isg-mysql-demo4-eventsubscriptionalarminstance",
................

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!

Was this page helpful?
0 / 5 - 0 ratings