-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
aws_cloudfront_function PreconditionFailed: The request failed because it didn't meet the preconditions in one or more request-header fields. #19529
Comments
This error is returned because the ETag value in state isn't equal to the current value at AWS (because the function was updated outside Terraform): terraform-provider-aws/aws/resource_aws_cloudfront_function.go Lines 159 to 182 in da4fb15
|
@hougholi why was this closed? I'm seeing the same issue. |
I worked around it by deleting the CloudFront function and letting Terraform recreate it. |
Thanks for reopening 👍 - yes I did the same, but it is still worth fixing I think - ideally manual changes would be detected and reset by terraform - they are ignored at the moment, I guess that's a separate issue though |
Same here. I would expect it to work again after running It appears that there's a bug with |
I now have this issue with a function in production - so I can't delete it and let Terraform recreate. So yeah it's worth fixing. |
Another workaround is to remove it from the state file (terraform state rm) and add it back in (terraform import) before updating. |
I have the same issue with origin-access-identities |
We've got the same issue, leading to an inconsistent build (occasional reruns work) which blocks us releasing anything with CloudFront Functions. |
I am interested in fixing this issue, it causes problems for us. I can see a few ways forward:
If a maintainer could confirm the preferred approach, I will code it up. |
(Not a maintainer but throwing in my 2c @alexjurkiewicz) I'd prefer option 1, because on other resources Terraform attempts to reset any changes (manual or otherwise) to the terraform representation of the infrastructure. For example, if I manually modify the desired number of tasks on an ECS service, terraform apply will set it back to the If we had to run PS. just spotted in the docs that |
Running for the same exception. I am fixing it by running with |
From: https://www.terraform.io/docs/cli/commands/refresh.html
Performing a plan/apply will refresh your state. The problem here is that with A separate issue that causes a similar precondition errors happens if a plan will modify both the distribution & cloudfront function that is published. The cloudfront function being published actually modifies the etag of the distribution. Which is where @alexjurkiewicz first proposal would be useful as it would help alleviate inter-resource etag conflicts. You can see this already being done for cloudfront distribution deletions terraform-provider-aws/aws/resource_aws_cloudfront_distribution.go Lines 1015 to 1036 in bae3b38
|
Thanks, this helped to resolve the error in my case. I have two functions in the same (CDK) terraform stack. Applying with |
Hi there, Can reproduce this with Terraform 1.0.2/1.0.5 and provider version 3.56.0. |
This is still occurring - It's not an issue with Lambda@Edge functions so I'm assuming the same sort of rules etc. should apply here too? |
This functionality has been released in v3.65.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I have just experiencing this happening with AWS provider v3.73.
the weird thing is re-applying might fix the error. |
Your failure is when updating the cloudfront distribution, not the cloudfront function. Theres a separate issue I described in this comment #19529 (comment). I'll create a bug report on it. |
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. |
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.13.5
Provider v3.42.0
Affected Resource(s)
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
https://gist.github.com/hougholi/0f099da4f04599fbe26e38e0568b1f45
Expected Behavior
CloudFront function code should be updated.
Actual Behavior
Error: error updating CloudFront Function (dev-cloudfront-security-headers) configuration : PreconditionFailed: The request failed because it didn't meet the preconditions in one or more request-header fields.
status code: 412, request id: 38cb6e1b-b74a-4f1c-bb91-0c385e39c88d
Steps to Reproduce
Update CloudFront function code and run
terraform apply
.Important Factoids
The function already exists in AWS, this error only occurs when updating the code and trying to run
terraform apply
The text was updated successfully, but these errors were encountered: