Terraform: Cloudflare Cannot Update DNS Record as it already exists

Created on 11 Nov 2016  ยท  12Comments  ยท  Source: hashicorp/terraform

Terraform Version

Versio 0.7.7 and Version 0.7.10

Affected Resource(s)

Please list the resources as a list, for example:

  • Cloudflare Provider

Terraform Configuration Files

resource "cloudflare_record" "my_record" {
  domain = "<MY_DOMAIN>"
  name = "*.<MY_DOMAIN>"
  value = "<MY_VALUE>"
  type = "CNAME"
  ttl = 1
}

Debug Output

`cloudflare_record.my_record: Creating...
domain: "" => ""
hostname: "" => ""
name: "" => "*."
proxied: "" => "false"
ttl: "" => "1"
type: "" => "CNAME"
value: "" => ""
zone_id: "" => ""
Error applying plan:

1 error(s) occurred:

  • cloudflare_record.my_record: Failed to create record: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":81053,\"message\":\"An A, AAAA or CNAME record already exists with that host.\"}],\"messages\":[],\"result\":null}"`

Expected Behavior

The record should be updated.

Actual Behavior

Terraform failed and did not update the record

Steps to Reproduce

  1. terraform plan
bug providecloudflare

Most helpful comment

It's happening for me with Terraform v0.11.10 and provider.cloudflare v1.7.0 when I have a 2 type A subdomain entries for 2 different IPs and, for some reason, the IPs change order. I think the provider should detect this situation and not try to apply any changes.

All 12 comments

@ahosking Ohai! Is this record already managed in terraform, or had you created it manually in Cloudflare ahead of time?

I think cloudflare records need terraform import support in order to handle the second case.

I'm not so sure if this ticket is the place, but +1 from me for the cloudflare records terraform import support. This "Can not update as it already exists" error is quite annoying.

+1 from me as well. Currently facing the same issue mentioned in this issue while trying to manage a zone in CloudFlare that had records created via the UI.

@mwarkentin The flow to get to this point was;

  • Create record with terraform
  • Change record with terraform
  • After inconsistent amount of time observe the problem

Terraform import would definitely help here, but it's strange that when created with Terraform it would lose management of itself. I suspect a change was made to it in the GUI that threw Terraform out but can't verify at the moment.

Probably a duplicate of #7690

This is closed via #10910

This resolved?

I'm having the same problem, what's the solution ????

This is still happening in Terraform 0.11.7

It's happening for me with Terraform v0.11.10 and provider.cloudflare v1.7.0 when I have a 2 type A subdomain entries for 2 different IPs and, for some reason, the IPs change order. I think the provider should detect this situation and not try to apply any changes.

I'm having this issue with Terraform 0.12.6 (and Cloudflare provider 1.17.1) after following: https://www.sergeydotnet.com/using-terraform-with-azure-devops/. Can create new records but when I try and change the value of one of them it can't update it because the record already exists.

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pawelsawicz picture pawelsawicz  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

larstobi picture larstobi  ยท  3Comments

zeninfinity picture zeninfinity  ยท  3Comments