-
Notifications
You must be signed in to change notification settings - Fork 9k
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
cloudfront destroy failure #1074
Comments
I'm also getting this in 0.10.6 and deleting manually fixed it instantly. I think I might have interrupted a previous 'apply' - self-inflicted! |
Hi folks, @cannontrodder thank you for your feedback! @xenoterracide could you also try on your side? Thank you! |
deleting manually would cause the apply to go through, but a subsequent create/destroy was causing the problem to resurface (because of cloudfront's deactive -> delete workflow). It may work in 10, we haven't upgraded yet, I'll leave a note to update this in our upgrade ticket. |
Same here. 0.10.6, will try in 0.10.7 but not sure how to recreate. Also of note, if trying to do a refresh/apply/destroy on more than just the CF resources, TF just hangs with no output. I had a hunch it was CF so I targeted them specifically and this surfaced. |
0.10.8/aws 1.2
my guess is this was caused by my creating the distribution, and then trying to destroy it almost immediately as I troubleshoot another problem |
@Ninir I got this error again, googled it and found this thread where I had already commented! So at least others who get this issue can see this thread! Anyway, there are some issues I get from time to time with terraform which I now feel are extreme edge-cases caused by my behaviour as I develop a complex terraform stack. I'm iterating over and over - It's no surprise to me now that the issues I see are around destroying cloudfront distributions, rds instances and other resources that typically take a while to get up and running and a while to destroy. e.g., I've had cf distributions take 40 minutes to destroy. So, for those who follow, don't sweat this issue too much, just apply/destroy again. The only sane thing to do when an something in AWS fails to do as terraform asks is to shrug your shoulders and just say "that's the cloud for you". |
yeah, I've seen it take some 30-40 minutes on the long end, but that usually seems to happen when correcting some error or another, like if I stop a create in order to change something, but it's already started, it then takes longer to destroy it again. I think that perhaps the best strategy though, is to ensure your cloudfront resources are separate, so you don't have to destroy them when you destroy the things backing them. |
Just ran into this as well. Applying the same config again managed to destroy the same CF distribution that had failed (after 11 minutes), and completed successfully in the end. 👍
|
@jareware do you happen to have the debug logs from the failed apply? Unfortunately its really hard to troubleshoot or fix this issue without knowing exactly what is causing it. Any context helps! 😄 |
Sadly I don't. I'll try to keep this in mind for the future, though! |
I just hit this same error and I do have the debug logs. Given the fact that it's 32000 lines long and littered with possible "secret" data, how would you want to receive them? |
just hit the same error when using Terratest to test my code.
It seems like that's the problem. With the testing framework I am spawning a CF distribution, making some http calls until a 200 response occurs and then immediately destroy everything. My dirty fix was to sleep for 5minutes after CF answers with a 200... 😩 |
…figuration block argument `ConflictsWith` usage and fix various related issues with deployment timing References: * #7773 * #3077 * #1074 * #260 Here we remove the problematic `viewer_certificate` argument `ConflictsWith` schema configuration as it interferes with Terraform Module usage until Terraform 0.12 is more prevalent. More details: #7773 (comment) When writing acceptance testing to cover setting both the `viewer_certificate` configuration block `acm_certificate_arn` and `cloudfront_default_certificate` arguments being defined, the below error was consistently happening when the test configuration included `enabled = false`: ``` --- FAIL: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (1935.57s) testing.go:599: Error destroying resource! WARNING: Dangling resources may exist. The full state and error is shown below. Error: Error applying: 1 error occurred: * aws_cloudfront_distribution.test (destroy): 1 error occurred: * aws_cloudfront_distribution.test: CloudFront Distribution E3GDAPNU6UPO0O cannot be deleted: PreconditionFailed: The request failed because it didn't meet the preconditions in one or more request-header fields. status code: 412, request id: 4e73a086-3c33-11e9-832f-7732257f45e8 ``` While debugging this the following further issues were encountered: * The resource did not wait for deployment to complete on creation and updates so in the acceptance testing the deletion function was always handling `InProgress` operations. * Disabled distributions would always update the distribution on deletion to disable them without checking if it was necessary, causing unnecessary delays. * The `PreconditionFailed` error seemed to be related to some eventual consistency issue within CloudFront right after disabling the distribution, which was always done. Retrying was a sufficient workaround for the error. * The deletion process did not ignore `NoSuchDistribution` errors such as the below: ``` --- FAIL: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (1835.97s) testing.go:599: Error destroying resource! WARNING: Dangling resources may exist. The full state and error is shown below. Error: Error applying: 1 error occurred: * aws_cloudfront_distribution.test (destroy): 1 error occurred: * aws_cloudfront_distribution.test: CloudFront Distribution E2HQM77NFHV9T cannot be deleted: NoSuchDistribution: The specified distribution does not exist. ``` This changeset bundles all these fixes together as they are related. Previous output for `ConflictsWith` acceptance testing: ``` --- FAIL: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (1.64s) testing.go:538: Step 0 error: config is invalid: 2 problems: - aws_cloudfront_distribution.test: "viewer_certificate.0.acm_certificate_arn": conflicts with viewer_certificate.0.cloudfront_default_certificate - aws_cloudfront_distribution.test: "viewer_certificate.0.cloudfront_default_certificate": conflicts with viewer_certificate.0.acm_certificate_arn ``` Output from acceptance testing: ``` --- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (2.15s) --- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (2.19s) --- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (1915.48s) --- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (1958.08s) --- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (2121.58s) --- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (2123.60s) --- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (2126.73s) --- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (2126.82s) --- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (2176.09s) --- PASS: TestAccAWSCloudFrontDistribution_customOrigin (2178.92s) --- PASS: TestAccAWSCloudFrontDistribution_S3Origin (2178.98s) --- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (2179.08s) --- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (3251.14s) ```
The fix for |
This has been released in version 2.1.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
cloudfront destroy fails, this seems to be because cloudfront needs to deactivate first, and then delete. It seems that even if it has been disabled for a while (ran apply, it disabled, and failed, ran again, it failed again?)
so after
I just went in an clicked delete. If more info is needed I will try to supply.
The text was updated successfully, but these errors were encountered: