Skip to content

cloudflare_email_routing_dns - code 2007, Invalid Input: must be a a subdomains #5890

@mz1978

Description

@mz1978

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

cloudflare provider version 5.8.2
terraform v1.12.2

Affected resource(s)

cloudflare_email_routing_dns

Terraform configuration files

resource "cloudflare_email_routing_dns" "example_email_routing_dns" {
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
  name = "example.net"
}

Link to debug output

https://gist.github.com/mz1978/a8871851897b59fd4811a0c10489f387

Panic output

No response

Expected output

HTTP 200

Actual output

422 Unprocessable Entity {
│ "result": null,
│ "success": false,
│ "errors": [
│ {
│ "code": 2007,
│ "message": "Invalid Input: must be a a subdomains of some-domain.com"
│ }
│ ],
│ "messages": [
│ {
│ "code": 2007,
│ "message": "Invalid Input: must be a a subdomains of some-domain.com"
│ }
│ ]
│ }

Steps to reproduce

using resource with "name" parameter > error "has to be subdomain"
using resource without "name" parameter > name is mandatory ..

POST https://api.cloudflare.com/client/v4/zones/$ZONE_ID/email/routing/dns

with payload "name = some-domain.com"
results in similar error

without payload
main domain will be enabled for email routing ...

Additional factoids

below answer I got from Cloudflare support when asking regarding the corresponding API endpoint


You can now use the following endpoint without a payload to enable Email Routing for your zone domain: /zones/$ZONE_ID/email/routing/dns

API Reference: https://developers.cloudflare.com/api/resources/email_routing/subresources/dns/methods/create/

curl -X POST https://api.cloudflare.com/client/v4/zones/$ZONE_ID/email/routing/dns
-H 'Content-Type: application/json'
-H "X-Auth-Email: $CLOUDFLARE_EMAIL"
-H "X-Auth-Key: $CLOUDFLARE_API_KEY"

If you're trying to configure Email Routing for a subdomain, then you should include a payload like this:

curl -X POST https://api.cloudflare.com/client/v4/zones/$ZONE_ID/email/routing/dns
-H 'Content-Type: application/json'
-H "X-Auth-Email: $CLOUDFLARE_EMAIL"
-H "X-Auth-Key: $CLOUDFLARE_API_KEY"
-d '{
"name": "email-routing-subdomain.example.net"
}'

The error you're seeing — "Invalid Input: must be a subdomain of xxx" — likely occurred because the payload was incorrectly used when trying to configure the zone domain instead of a subdomain.


References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions