Terraform-provider-cloudflare: Unable to create MX records with "." as value

Created on 10 Mar 2021  ·  10Comments  ·  Source: cloudflare/terraform-provider-cloudflare

Hi there,
It seems that we are still unable to create MX records with "." as a value (check #References for the first issue).
This is for protecting a parked domain setting up a null MX

Terraform version

Terraform v0.14.7

  • provider registry.terraform.io/cloudflare/cloudflare v2.19.0

Affected resource(s)

  • cloudflare_record

Terraform configuration files

resource "cloudflare_record" "mx" {
  zone_id  = var.zone_id
  name     = "example.com"
  value    =  "."
  priority = 0
  type     = "MX"
  proxied  = false
}

Debug output

https://gist.github.com/AlessioCasco/be4a674cfee5922c697d79cf9b64d10d

Expected behaviour

The MX record should be created with "." as value.
I am able to do it using the Cloudflare website

Actual behaviour

Terraform exits with an error:

Error: failed to create DNS record: HTTP status 400: DNS Validation Error (1004)
  on ../../modules/cloudflare/zone/main.tf line 98, in resource "cloudflare_record" "mx":
  98: resource "cloudflare_record" "mx" {

Steps to reproduce

  1. terraform apply

References

This issue was first reported in this issue: #944 and linked with #943

Community note

  • Please vote on this issue by adding a 👍 reaction
    to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull
    request, please leave a comment
kinbug needs-triage

All 10 comments

Thanks again @AlessioCasco; I just realised we shipped the fixes for cloudflare-go to understand the new data type but Terraform needs to change from d.GetOk to d.GetOkExists 🤦‍♂️. I'll cut a hotfix for this one as soon as CI is green.

Can you please try v2.19.1? I've just cut a release so it should be publicly available in the next 30-60 minutes .

Many thanks, Jacob.
Sure, I will give it a try and let you know for sure.

I'm sorry to say this, but I'm unable to plan or to apply with 2.19.1 (reverting back to 2.19.0 works).

During one apply attempt, terraform crashed with the following error:

The output is truncated, let me know if you want the whole crash.log file

[...]
Error: rpc error: code = Canceled desc = context canceled


2021-03-11T00:45:26.919Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: 2021/03/11 00:45:26 [DEBUG] Data found in config: map[string]interface {}{}
2021-03-11T00:45:26.921Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: panic: runtime error: invalid memory address or nil pointer dereference
2021-03-11T00:45:26.921Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x103cdac]
2021-03-11T00:45:26.921Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: 
2021-03-11T00:45:26.921Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: goroutine 384 [running]:
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: github.com/cloudflare/terraform-provider-cloudflare/cloudflare.resourceCloudflareRecordRead(0xc0002ccb60, 0x13417c0, 0xc00029e180, 0xc0002ccb60, 0x0)
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  github.com/cloudflare/terraform-provider-cloudflare/cloudflare/resource_cloudflare_record.go:442 +0xacc
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00015aea0, 0xc00050e8c0, 0x13417c0, 0xc00029e180, 0xc00073cbb8, 0x0, 0x0)
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  github.com/hashicorp/[email protected]/helper/schema/resource.go:460 +0x129
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00073c368, 0x1516240, 0xc00099ccf0, 0xc000a9aa80, 0xc00073c368, 0xc00099ccf0, 0xc0004b0ba0)
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  github.com/hashicorp/[email protected]/internal/helper/plugin/grpc_provider.go:525 +0x3dd
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x12fd8c0, 0xc00073c368, 0x1516240, 0xc00099ccf0, 0xc000a9aa20, 0x0, 0x1516240, 0xc00099ccf0, 0xc0007ac240, 0x210)
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  github.com/hashicorp/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3269 +0x214
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000746700, 0x1521a00, 0xc000703800, 0xc0007a6200, 0xc00044ced0, 0x1c0c510, 0x0, 0x0, 0x0)
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  google.golang.org/[email protected]/server.go:1171 +0x522
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: google.golang.org/grpc.(*Server).handleStream(0xc000746700, 0x1521a00, 0xc000703800, 0xc0007a6200, 0x0)
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  google.golang.org/[email protected]/server.go:1494 +0xcc5
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000040550, 0xc000746700, 0x1521a00, 0xc000703800, 0xc0007a6200)
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  google.golang.org/[email protected]/server.go:834 +0xa5
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1: created by google.golang.org/grpc.(*Server).serveStreams.func1
2021-03-11T00:45:26.922Z [DEBUG] plugin.terraform-provider-cloudflare_v2.19.1:  google.golang.org/[email protected]/server.go:832 +0x1fd
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redacted.se\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redacted.com.sg\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redacted.sg\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redacted.ro\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redacted.lt\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redacted.in\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redcated.cloud\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redcated.com.au\"]": visit complete
2021/03/11 00:45:26 [TRACE] vertex "module.cloudflare_zone.cloudflare_record.dkim[\"redacted.eu\"]": visit complete
2021-03-11T00:45:26.929Z [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/2.19.1/linux_amd64/terraform-provider-cloudflare_v2.19.1 pid=8056 error="exit status 2"
[...]

gah. can you please provide your config and state so I can dig into this with a test case to match?

I'll do it first thing tomorrow, it's quite late here in London :-)
Any preferred method for sending this over privately?

Thanks again
Alessio

sure, email it over to jacob.bednarz (at) hey.com

rolling this over into #988

Sorry, Jacob, I'm going to send you the data tomorrow morning UK time.

no worries! i'll see what i can do in the meantime as we have a few others experiencing this too.

Was this page helpful?
0 / 5 - 0 ratings