Requirements
- Terraform >= 1.1.x (older versions may work but are entirely untested)
- OpenTofu
- Go >= 1.22
- ClouDNS API credentials and a pre-existing DNS zone manageable by the user/sub-user associated with said credentials
Building The Provider
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
$ go install
Adding Dependencies
This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go
modules.
To add a new dependency github.com/author/dependency
to your OpenTofu/Terraform provider:
go get github.com/author/dependency
go mod tidy
Then commit the changes to go.mod
and go.sum
.
Using the provider
Ensure that you have an API user/sub-user on ClouDNS (requires a paid subscription with reseller access).
Note that using a sub-user which you delegate a specific zone to is a much safer approach and should always be your first choice
Once that is done, you must pre-create the zones you will want to manage on ClouDNS side (technically they are manageable through the API)
Import Records
Records can be imported using:
terraform import ADDR "zone/id"
Example record and its import command:
resource "cloudns_dns_record" "some-record" {
# ID: 123456789
# something.cloudns.net 600 in A 1.2.3.4
name = ""
zone = "something.cloudns.net"
type = "A"
value = "1.2.3.4"
ttl = "600"
}
terraform import cloudns_dns_record.some-record "something.cloudns.net/123456789"
Import Zones
Zones can be imported using:
terraform import ADDR "domain"
Example zone and its import command:
resource "cloudns_dns_zone" "some-zone" {
# example.com
domain = "example.com"
type = "master"
}
terraform import cloudns_dns_zone.some-zone "example.com"
Import Failover
Failover can be imported using:
terraform import ADDR recordId
Example failover and its import command:
resource "cloudns_dns_failover" "testzone-bg-http" {
#recordId = 123456789
domain = cloudns_dns_zone.sub-testzone-bg.domain
recordid = cloudns_dns_record.sub-testzone-bg-a["something"].id
checktype = "9"
port = "90"
downeventhandler = "0"
upeventhandler = "0"
mainip = cloudns_dns_record.sub-testzone-bg-a["something"].value
depends_on = [ cloudns_dns_zone.sub-testzone-bg ]
}
terraform import cloudns_dns_failover.testzone-bg-http 123456789