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

digitialocean_record will not create an SRV record with a Port value of 0 #475

Closed
garethsaxby opened this issue Aug 5, 2020 · 1 comment
Assignees
Labels

Comments

@garethsaxby
Copy link

Terraform Version

terraform -v
Terraform v0.12.29
+ provider.digitalocean v1.20.0

Affected Resource(s)

digitalocean_record

Terraform Configuration Files

resource "digitalocean_domain" "main" {
  name = "example.com"
}

resource "digitalocean_record" "srv" {
  domain   = digitalocean_domain.main.name
  type     = "SRV"
  name     = "_caldav._tcp"
  priority = 0
  weight   = 0
  port     = 0
  value    = "@"
  ttl      = 3600
}

Expected Behavior

The DNS SRV record should be created with the valid value of 0 for the port number, subject to the domain being created successfully.

Actual Behavior

The terraform configuration is hard stopped by the following error, and an apply does not happen:


Error: expected port to be in the range (1 - 65535), got 0

  on dns.tf line 5, in resource "digitalocean_record" "srv":
   5: resource "digitalocean_record" "srv" {

Steps to Reproduce

  1. Run a terraform plan against the example Terraform Configuration file.

Important Factoids

A port number of 0 is a valid in an SRV record as per RFC 2782, and using a 0 for the port number works both over the Digital Ocean API and web interface successfully.

For a Digital Ocean API example, first create a valid domain, then run the following with the domain field updated and your own token in place of my redacted token (I have formatted the output for better legibility):

$ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <REDACTED" -d '{"type":"SRV","name":"_caldav._tcp","data":"www.example.com.","priority":0,"port":0,"ttl":1800,"weight":0,"flags":null,"tag":null}' "https://api.digitalocean.com/v2/domains/gs-test-example.com/records"

{
  "domain_record": {
    "id": 109234109,
    "type": "SRV",
    "name": "_caldav._tcp",
    "data": "www.example.com",
    "priority": 0,
    "port": 0,
    "ttl": 1800,
    "weight": 0,
    "flags": null,
    "tag": null
  }
}

References

Digital Ocean API - https://developers.digitalocean.com/documentation/v2/#create-a-new-domain-record
RFC 2782 - https://tools.ietf.org/html/rfc2782

@andrewsomething
Copy link
Member

Thanks for flagging this. Once this fix lands in godo, we can get this fixed here as well: digitalocean/godo#360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants