Skip to content

[Bug]: (also doc issue) importing cloudfront response header policy includes etag which is undocumented as an argument and causes apply failures #38244

Closed
@automaticgiant

Description

@automaticgiant

Terraform Core Version

1.4.6

AWS Provider Version

5.56.1

Affected Resource(s)

resource cloudfront_response_headers_policy

Expected Behavior

one or more of the following:

  • when importing and generating config, etag should not have been added to the resource
  • the resource should not have accepted the etag argument
  • the documentation should mention etag as an argument

Actual Behavior

generated config with etag argument

two applies of header changes after the import worked fine

the third could not apply

(plan listed an etag change)

Relevant Error/Panic Output Snippet

│ Error: updating CloudFront Response Headers Policy (edb1ee71-912d-4571-af09-1954a5cb5db0): operation error CloudFront: UpdateResponseHeadersPolicy, https response error StatusCode: 412, RequestID: 73a27780-3429-4e55-9a94-745ef688344e, PreconditionFailed: The request failed because it didn't meet the preconditions for this operation.

Terraform Configuration Files

resource "aws_cloudfront_response_headers_policy" "policy" {
  count = var.APP_IAC_STAGE == "prod" ? 1 : 0
  etag    = "E13Q6A55DBZB7M"
  name    = "REDACTED"
  custom_headers_config {
    items {
      header   = "Permissions-Policy"
      override = true
      value    = "REDACTED"
    }
  }
  security_headers_config {
    content_security_policy {
      content_security_policy = "REDACTED"
      override                = true
    }
    content_type_options {
      override = true
    }
    frame_options {
      frame_option = "SAMEORIGIN"
      override     = true
    }
    referrer_policy {
      override        = true
      referrer_policy = "strict-origin"
    }
    strict_transport_security {
      access_control_max_age_sec = 31536000
      include_subdomains         = true
      override                   = true
      preload                    = false
    }
  }
}

Steps to Reproduce

presumably, generate config with import from an existing resource (with etag), then apply changes until failure (unclear why the first two changes were ok)

Debug Output

fixed before debug logging was enabled by removing etag argument from config

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

Labels

breaking-changeIntroduces a breaking change in current functionality; usually deferred to the next major release.bugAddresses a defect in current functionality.service/cloudfrontIssues and PRs that pertain to the cloudfront service.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions