Skip to content
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

Unable to create MX records with "." as value #984

Closed
AlessioCasco opened this issue Mar 10, 2021 · 12 comments · Fixed by #986
Closed

Unable to create MX records with "." as value #984

AlessioCasco opened this issue Mar 10, 2021 · 12 comments · Fixed by #986
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@AlessioCasco
Copy link

AlessioCasco commented Mar 10, 2021

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
@AlessioCasco AlessioCasco added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 10, 2021
@jacobbednarz
Copy link
Member

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.

@jacobbednarz
Copy link
Member

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 .

@AlessioCasco
Copy link
Author

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

@AlessioCasco
Copy link
Author

AlessioCasco commented Mar 11, 2021

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"
[...]

@jacobbednarz
Copy link
Member

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

@AlessioCasco
Copy link
Author

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

@jacobbednarz
Copy link
Member

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

@jacobbednarz
Copy link
Member

rolling this over into #988

@AlessioCasco
Copy link
Author

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

@jacobbednarz
Copy link
Member

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

@cpl
Copy link

cpl commented Jul 31, 2022

Hey @jacobbednarz, sorry to re-open this discussion, but this used to work for me until 3.14, now that I upgraded to 3.20 (with TF 1.2.6), I am getting the following error:

│ Error: either 'value' (present: false) or 'data' (present: false) must be provided
│ 
│   with module.dns-noemail["...redacted..."].cloudflare_record.mx,
│   on ../../modules/dns-noemail/20-records.tf line 23, in resource "cloudflare_record" "mx":
│   23: resource "cloudflare_record" "mx" {
│ 

This is the resource

resource "cloudflare_record" "mx" {
  name     = "@"
  type     = "MX"
  value    = "."
  priority = 0

  zone_id = data.cloudflare_zone.current.id
}

If I can provide more info, or if I should open a new issue, please let me know. Thanks!

@dhess
Copy link

dhess commented Aug 22, 2022

We're having the same problem since upgrading. Existing records with value = "." are fine, but when we try to create new ones, they fail with the Error: either 'value' (present: false) or 'data' (present: false) must be provided error.

I created them manually in the web UI, hoping that Terraform would recognize that they'd already been created and that no state changes were required, but it claims the records don't exist and wants to create them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants