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.82k stars 9.17k forks source link

[Bug]: cloudwatch_event_target.retryPolicy.maximumEventAgeInSeconds is not optional #38265

Open fmichaut-diff opened 4 months ago

fmichaut-diff commented 4 months ago

Terraform Core Version

1.9.1

AWS Provider Version

5.48.0

Affected Resource(s)

Expected Behavior

Declaring a resource like :

resource "aws_cloudwatch_event_target" "this" {
  rule = var.rule
  arn  = var.arn
  [...]
  retry_policy {
    maximum_retry_attempts = var.retry_policy_max_attempts
  }
}

Should succeed since the maximum_event_age_in_seconds field of retry_policy is optional, and should be sent as null (or omitted ?) to AWS on apply.

Actual Behavior

Terraform defaults that maximum_event_age_in_seconds field to 0 if omitted, which results in a 400 error from AWS

Relevant Error/Panic Output Snippet

│ Error: creating EventBridge Target (XXXXXXX): operation error EventBridge: PutTargets, https response error StatusCode: 400, RequestID: 457116d9-87ea-40a2-861a-82957cdf2341, api error ValidationException: 1 validation error detected: Value '0' at 'targets.1.member.retryPolicy.maximumEventAgeInSeconds' failed to satisfy constraint: Member must have value greater than or equal to 60
│
│   with module.catalog_event_rules["XXXXX"].module.event_rule_targets["XXXXX"].aws_cloudwatch_event_target.this,
│   on ../modules/event_bridge/rules/event_target/main.tf line 1, in resource "aws_cloudwatch_event_target" "this":
│    1: resource "aws_cloudwatch_event_target" "this" {
│

Terraform Configuration Files

resource "aws_cloudwatch_event_target" "this" {
  rule = "some_exsiting_rule"
  arn  = "some_existing_resource_arn"
  retry_policy {
    maximum_retry_attempts = 2
  }
}

Steps to Reproduce

Try to apply the config. After typing yes, terraform will fail with the aformentioned error

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 4 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue