hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

[Bug]: Eventbridge rule changed from enabled to disabled without showing in Terraform plan #35077

Open shalev123d opened 8 months ago

shalev123d commented 8 months ago

Terraform Core Version

1.3.6

AWS Provider Version

5.31.0

Affected Resource(s)

aws_cloudwatch_event_rule

Expected Behavior

We have the rule with ignore_changes on is_enabled, which is set to disabled in the code, but the rule is enabled in AWS. I tried to change the rule's event pattern, and the terraform plan output showed only the expected change is about to occur (pattern change) but also changed the rule from enabled with disabled, even though it's in ignore_changes.

TF Plan output -

 # aws_cloudwatch_event_rule.rule will be updated in-place
  ~ resource "aws_cloudwatch_event_rule" "rule" {
      ~ event_pattern  = jsonencode(
          ~ {
              ~ detail      = {
                  ~ object = {
                      + size = [
                          + {
                              + numeric = [
                                  + ">",
                                  + 0,
                                ]
                            },
                        ]
                        # (1 unchanged element hidden)
                    }
                    # (1 unchanged element hidden)
                }
                # (2 unchanged elements hidden)
            }
        )
        id             = "my-rule"
        name           = "my-rule"
        tags           = {}
        # (5 unchanged attributes hidden)
    }

Actual Behavior

The rule changed from enabled to disabled

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_cloudwatch_event_rule" "rule" {
  name           = "my-rule"
  event_bus_name = "default"
  is_enabled          = false
  event_pattern  = <<EOF
{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"]
}
EOF

  lifecycle {
    ignore_changes = [is_enabled]
  }
}

Steps to Reproduce

  1. Create a rule with the above configuration
  2. Change the rule manually to enabled
  3. apply a pattern change, and the rule is changing from enabled to disabled, even with ignore_changes

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 8 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

shalev123d commented 8 months ago

Critical update - after adjusting to the "state" parameter, it is still ignoring the "ignore_changes" and it has disabled the eventbridge rules (enabled manually, disabled in HCL)

image (13) image (14) image (15)

snir-katriel commented 6 months ago

Hi, we're currently preventing ALL updates to our production Terraform managed event rules due to this issue. Would highly appreciate your attention here :)

yotam097 commented 3 weeks ago

Hi, we're currently facing the same issue. Are there any updates?