ClouDNS / terraform-provider-cloudns

A Terraform provider for ClouDNS
Mozilla Public License 2.0
1 stars 0 forks source link

Provider is incomplete and broken #4

Closed sempervictus closed 4 months ago

sempervictus commented 4 months ago

DNS zone resources cannot be imported and are broken when created - simply creating one, then running the same (unchanged) apply action will attempt re-create it then fail to destroy the original object with

cloudns_dns_zone.somezone-com: Destroying... [id=somezone.com]
╷
│ Error: Missing domain-name
│ 
│ 
╵

trying to create a zone and records all in the same apply operation produces:

cloudns_dns_zone.somezone-com: Creating...
cloudns_dns_zone.somezone-com: Creation complete after 1s [id=somezone.com]
╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for cloudns_dns_record.somezone-com-mx["@"] to include new values learned so far during apply, provider "registry.opentofu.org/cloudns/cloudns" produced an invalid new value for .zone: was cty.StringVal("somezone.com"), but
│ now cty.StringVal("").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

The provider is also unable to import resources

sempervictus commented 4 months ago

We're looking at API-driven providers which have a TF provider to escape GoDaddy's decision to pay-gate their API. Hoping ClouDNS might offer this functionality - are there any plans to finalize this provider in the near term, or should we come back in a bit to see how this effort is going?

Venkoul99 commented 4 months ago

Hello,

Is it possible to provide the tf file for the DNS zone creation that is applied so we can check further?

Is the tf provider used with API sub user or API user?

sempervictus commented 4 months ago

Thanks for pinging back. the relevant TF code is:

locals {
  a = {
    "@": "127.127.127.127",
    "*": "127.127.127.127",
    "something": openstack_networking_floatingip_v2.i1_pub.address,
    "somethingelse": openstack_networking_floatingip_v2.i2_pub.address
  }
  mx = {
    "@": "smtp.relay"
  }
  cname = {
    "www": "@",
  }
  txt = {
    "@": "v=spf1 include:spf.smtp.relay ~all"
  }
}
# https://www.cloudns.net/wiki/article/516/
resource "cloudns_dns_zone" "somedomain-com" {
  domain = "somedomain.com"
  type = "master"
}
resource "cloudns_dns_record" "somedomain-com-a" {
  for_each = local.a
  name = each.key
  zone = cloudns_dns_zone.somedomain-com.domain
  type = "A"
  value = each.value
  ttl = "600"
  depends_on = [ cloudns_dns_zone.somedomain-com ]
}
resource "cloudns_dns_record" "somedomain-com-mx" {
  for_each = local.mx
  name = each.key
  zone = cloudns_dns_zone.somedomain-com.domain
  type = "MX"
  value = each.value
  ttl = "600"
  depends_on = [ cloudns_dns_zone.somedomain-com ]
  priority = ((index(keys(local.mx), each.key) + 1 ) * 10)
}
resource "cloudns_dns_record" "somedomain-com-cname" {
  for_each = local.cname
  name = each.key
  zone = cloudns_dns_zone.somedomain-com.domain
  type = "CNAME"
  value = each.value
  ttl = "600"
  depends_on = [ cloudns_dns_zone.somedomain-com ]
}
resource "cloudns_dns_record" "somedomain-com-txt" {
  for_each = local.txt
  name = each.key
  zone = cloudns_dns_zone.somedomain-com.domain
  type = "TXT"
  value = each.value
  ttl = "600"
  depends_on = [ cloudns_dns_zone.somedomain-com ]
}

The API key is for the main account (only account) created.

Venkoul99 commented 4 months ago

Hello,

We have done some fixes on the issue and released a new v1.0.1.

Could you please update the version in the provider tf and try once again to create the test zone and records?

sempervictus commented 4 months ago

Thank you @Venkoul99! Awesome turn-around:

cloudns_dns_zone.somedomain-com: Creating...
cloudns_dns_zone.somedomain-com: Creation complete after 1s [id=somedomain.com]
cloudns_dns_record.somedomain-com-a["@"]: Creating...
cloudns_dns_record.somedomain-com-mx["@"]: Creating...
cloudns_dns_record.somedomain-com-cname["www"]: Creating...
cloudns_dns_record.somedomain-com-txt["@"]: Creating...
cloudns_dns_record.somedomain-com-a["*"]: Creating...
cloudns_dns_record.somedomain-com-cname["www"]: Creation complete after 1s [id=501294762]
cloudns_dns_record.somedomain-com-a["@"]: Creation complete after 1s [id=501294772]
cloudns_dns_record.somedomain-com-mx["@"]: Creation complete after 1s [id=501294776]
cloudns_dns_record.somedomain-com-txt["@"]: Creation complete after 2s [id=501294780]
cloudns_dns_record.somedomain-com-a["*"]: Creation complete after 2s [id=501294782]

have not tried importing resources yet but looks like state is now consistent:

No changes. Your infrastructure matches the configuration.
Venkoul99 commented 4 months ago

Thank you for the update @sempervictus !

We'll go ahead and close this issue for now. If you encounter any further problems or have any other questions, please don't hesitate to reach out to us again.