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

CW event rules should be teleted after resources they are depending of #18095

Closed
matthieu-front opened this issue May 22, 2018 · 4 comments
Closed

Comments

@matthieu-front
Copy link

Terraform Version

terraform -v
Terraform v0.11.7
+ provider.aws v1.16.0

Terraform Configuration Files

resource "aws_cloudwatch_event_rule" "my-schedule" {
  name                = "my-schedule"
  description         = "Fires every day at 4PM CEST / 7 AM PST."
  schedule_expression = "cron(0 14 * * ? *)"
}
resource "aws_cloudwatch_event_target" "my-target" {
  rule      = "${aws_cloudwatch_event_rule.my-schedule.name}"
  target_id = "my-lambda"
  arn       = "${aws_lambda_function.my-lambda.arn}"
}

Crash Output


* aws_cloudwatch_event_rule.my-schedule: Error deleting CloudWatch Event Rule: ValidationException: Rule can't be deleted since it has targets.
	status code: 400, request id: XXXXXX

Expected Behavior

Terraform should have removed the lambda function before attempting to remove the cloudwatch events rule linked to this lambda function. In this case, the events rule is only used to one lambda function and they are both deployed and updated only with Terraform.

Actual Behavior

Terraform attempts to remove the CW events rule before the Lambda function that used it, so everything is okay at the end but the CW events rule is not removed and the error message pasted above is displayed.

Steps to Reproduce

Create a template with a lambda function and associated CW event periodic scheduling, appy this template and then attempt to modify it (rename resources) or delete it.

@eddideku
Copy link

eddideku commented Mar 28, 2019

I ran into similar issue where I cannot delete CW Event Rule due to targets being associated with the rule. I cannot remove all the rules via terraform or AWS Console.

  • module.dataservice_m.aws_cloudwatch_event_rule.this_rule (destroy): 1 error(s) occurred:
  • aws_cloudwatch_event_rule.this_rule: Error deleting CloudWatch Event Rule: ValidationException: Rule can't be deleted since it has targets.
    status code: 400, request id: f6920c4a-512f-11e9-890d-037429c89b7f

@hashibot
Copy link
Contributor

Hello! 🤖

This issue relates to an older version of Terraform that is no longer in active development, and because the area of Terraform it relates to has changed significantly since the issue was opened we suspect that the issue is either fixed or that the circumstances around it have changed enough that we'd need an updated issue report in order to reproduce and address it.

If you're still seeing this or a similar issue in the latest version of Terraform, please do feel free to open a new bug report! Please be sure to include all of the information requested in the template, even if it might seem redundant with the information already shared in this issue, because the internal details relating to this problem are likely to be different in the current version of Terraform.

Thanks!

@mihaibaumgarten
Copy link

Added again bug report on the latest version of now 0.12.8 #22767

@ghost
Copy link

ghost commented Sep 27, 2019

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Sep 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants