Skip to content

[Bug]: aws_cloudwatch_metric_alarm: Inconsistent plan when depending on data resource #34661

@dennis-grunert

Description

@dennis-grunert

Terraform Core Version

1.6.4

AWS Provider Version

5.28.0

Affected Resource(s)

aws_cloudwatch_metric_alarm

Expected Behavior

When following the README.md of the minimal example repository, the apply should happen without any error.

Actual Behavior

The apply fails with the following error:

Error: Provider produced inconsistent final plan

When expanding the plan for aws_cloudwatch_metric_alarm.loadbalancer_high5xx to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .metric_query: planned set element
cty.ObjectVal(map[string]cty.Value{"account_id":cty.StringVal(""), "expression":cty.StringVal(""), "id":cty.StringVal("m1"), "label":cty.StringVal(""), "metric":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"dimensions":cty.UnknownVal(cty.Map(cty.String)),
"metric_name":cty.StringVal("HTTPCode_Target_5XX_Count"), "namespace":cty.StringVal("AWS/ApplicationELB"), "period":cty.NumberIntVal(60), "stat":cty.StringVal("Sum"), "unit":cty.StringVal("Count")})}), "period":cty.NullVal(cty.Number), "return_data":cty.True}) does not correlate
with any element in actual.

This is a bug in the provider, which should be reported in the provider's own issue tracker.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

A minimal example to reproduce the inconsistent plan is available here.

Steps to Reproduce

Follow the instructions of the README.md of the above repository to reproduce the issue.

Debug Output

No response

Panic Output

No response

Important Factoids

The minimal example creates an Beanstalk Environment. With a data.aws_lb resource, the (application) load balancer belonging to the Beanstalk is extracted and used in a CloudWatch alarm.

When a setting in the Beanstalk that has nothing to do with the load balancer is changed later, an inconsistent plan for the CloudWatch alarm is shown.

Due to the nature of the Beanstalk being created with a CloudFormation stack, the ARN of the load balancer is only known to the data resource at the apply phase. But it is unclear why an inconsistent plan is created when the ARN of the load balancer does not change in the end.

References

Minimal example to reproduce: https://github.com/dennis-grunert/minimal-example-beanstalk

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/cloudwatchIssues and PRs that pertain to the cloudwatch service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions