Terraform-provider-aws: Error-deleting-CloudWatch-Rule

Created on 23 Aug 2017  ·  10Comments  ·  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @mhmdio as hashicorp/terraform#15863. It was migrated here as a result of the provider split. The original body of the issue is below._


Terraform Version

Terraform v0.9.11

Terraform Configuration Files

resource "aws_cloudwatch_event_rule" "cloudwatch_to_s3" {
  name                = "cloudwatch-to-s3"
  description         = "copy cloudwatch VPC flow logs to s3"
  schedule_expression = "cron(0 0 * * ? *)"
}

resource "aws_cloudwatch_event_target" "cloudwatch_to_s3" {
  rule      = "${aws_cloudwatch_event_rule.cloudwatch_to_s3.name}"
  target_id = "cloudwatch_to_s3"
  arn       = "${aws_lambda_function.cloudwatch_to_s3.arn}"
}

Debug Output

https://gist.github.com/mhmdio/e2ef142eda0c0d667583b35f5716815e

Expected Behavior

Terraform should remove CW Event targets then remove the rule.

Actual Behavior

Terraform try to remove the CW Event rule before deleting CW Event targets.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. create a module from gist resources
  2. terraform get
  3. terraform apply
bug serviccloudwatchevents

Most helpful comment

Any solution to this problem yet?

All 10 comments

This is likely due to the fact that many AWS services including CloudWatch are eventually consistent. Given the configuration above, Terraform should have ordered the operations properly however CloudWatch likely had not fully propagated the target deletion internally before Terraform sent the rule deletion request. In many places we handle this by adding retry code around these operations.

Any solution to this problem yet?

What workarounds are available for this problem?

2 years since the issue was reported with no resolution. when can this be fixed, or a workaround provided?

Same issue here

Any news? This annoying bug breaks our pipelines regularly.

Potential fix submitted: https://github.com/terraform-providers/terraform-provider-aws/pull/11475

Please see the pull request description for additional information.

The eventual consistency retries and RemoveTargets API call FailedEntry handling have been merged and will release with version 2.45.0 of the Terraform AWS Provider, Thursday this week.

If you are still encountering issues after the release of version 2.45.0, please open a new bug report following the issue template and we will take a fresh look. 👍

This has been released in version 2.45.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'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