hashicorp / learn-terraform-cloudflare-static-website

https://learn.hashicorp.com/tutorials/terraform/cloudflare-static-website
Mozilla Public License 2.0
21 stars 19 forks source link

Error: Error creating S3 bucket: Error creating S3 bucket mydomainexample.io, retrying: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. #1

Closed vodelerk closed 3 years ago

vodelerk commented 3 years ago

hi, I'm following this tutorial: https://learn.hashicorp.com/tutorials/terraform/cloudflare-static-website?in=terraform/aws

with the Cloudflare approach, but when I try terraform apply, I'm getting this error:

│ Error: Error creating S3 bucket: Error creating S3 bucket mydomainexample.io, retrying: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. │ status code: 409, request id: AK7XAJQP15Z5N33T, host id: fNT/GTtL3i3DoMa8UxO+dd0Z0cBm7xbqyntk2MQwjgZyzFFNaXiq5BNE2HvFtjhGZ4mgEJ6PdrY= │ │ with aws_s3_bucket.site, │ on main.tf line 7, in resource "aws_s3_bucket" "site": │ 7: resource "aws_s3_bucket" "site" { │ ╵ ╷ │ Error: Error creating S3 bucket: Error creating S3 bucket www.mydomainexample.io, retrying: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. │ status code: 409, request id: AK7PB2E5CQHKA1G1, host id: 4d3pfx/ecquDyNmY76XK5J+aW6zZjcUDNkCRiWJUymJLHrsYW5TWIl+PpuP6AdKruHFyrudjc0M= │ │ with aws_s3_bucket.www, │ on main.tf line 17, in resource "aws_s3_bucket" "www": │ 17: resource "aws_s3_bucket" "www" { │ ╵ ╷ │ Error: expected DNS record to not already be present but already exists │ │ with cloudflare_record.www, │ on main.tf line 62, in resource "cloudflare_record" "www": │ 62: resource "cloudflare_record" "www" { │

any advice?

Thanks,

im2nguyen commented 3 years ago

Hi @vodelerk, there are two errors here! I think you tried to re-run this configuration.

  1. The S3 bucket error (OperationAborted: A conflicting conditional operation is currently in progress) is due to you trying to create a bucket that's already taken (but in the process of being deleted). If you wait a couple of minutes, you should able able to run the config without any issues. You can read more about this error in the AWS docs.
  2. The DNS record error (Error: expected DNS record to not already be present but already exists) means that the DNS record is already defined in Cloudflare. You need to delete the record in Cloudflare before trying again. The Cloudflare cloudflare_record resource assumes that the record doesn't exist and attempts to create it. Since it does exist, the API and the provider returns an error.
vodelerk commented 3 years ago

As usual, you are right my friend @im2nguyen , the issue was that when I was trying to add the domain to Cloudflare, there were 2 DNS records already set up, an A type and CNAME, so I have to manually delete them in order to deploy correctly. I can confirm that the Cloudfare approach and ACM works as expected :)