Closed kimdre closed 7 months ago
I have been able to import the existing domain into a inwx_domain record but didn't try creating the domain that way.
Yes, you could go to the web UI to create a domain entry on the nameserver for your external domain and then import it into your terraform state, but that's not really a good way to do that in my opinion.
Absolutely. I am currently working on building my own platform and as part of that it would be cool to first fetch with the ordinary API if a domain is available and if so add it to the terraform repo and let terraform claim it.
If the normal Domainrobot API can do it, why is the terraform provider not able to do it? Here the link to the API documentation for the function domain.create: https://www.inwx.de/de/help/apidoc/f/ch02s09.html#domain.create
Maybe a stupid question but how does the addition of an additional resource type solve this problem?
You can create zones with this new ressource without having to go to the web ui and you can also reference that ressource in the domain
field for inwx_nameserver_record
.
I still don't quite understand: the inwx_domain
type contains additional data like contact information, etc. Will inwx_nameserver
now create an actual domain? Because it does not actually represent a nameserver. So far inwx_nameserver_record
expects a string for domain. Do I understand you correctly that the id of one of the new inwx_nameserver
entries would belong in that field?
No, to create/register the actual domain you still use the inwx_domain
resource and define contacts with inwx_domain_contact
. However to define dns records for your domain, your first need to create a zone for your domain on a nameserver that will contain those records. Therefore you now have the new inwx_nameserver
resource.
Zones are a separate layer between their domain and its dns records, so you could separate your records on different nameservers (e.g. if you have multiple teams that work on different projects with their own subdomains on the same domain)
An example would look like this:
resource "inwx_domain_contact" "example_person" {
type = "PERSON"
name = "Example Person"
street_address = "Example Street 0"
city = "Example City"
postal_code = 00000
state_province = "Example State"
country_code = "EX"
phone_number = "+00.00000000000"
email = "person@example.invalid"
}
resource "inwx_domain" "example_com" {
name = "example.com"
nameservers = [
"ns.inwx.de",
"ns2.inwx.de"
]
period = "1Y"
renewal_mode = "AUTOEXPIRE"
transfer_lock = true
contacts {
// references to terraform managed contact "example_person"
registrant = inwx_domain_contact.example_person.id
admin = inwx_domain_contact.example_person.id
tech = inwx_domain_contact.example_person.id
billing = inwx_domain_contact.example_person.id
}
extra_data = {
// Enable e.g. whois protection
"WHOIS-PROTECTION": "1" // 1 == bool true
}
}
resource "inwx_nameserver" "example_com_ns" {
domain = inwx_domain.example_com.name
type = "MASTER"
nameservers = [
"ns.inwx.de",
"ns2.inwx.de"
]
}
resource "inwx_nameserver_record" "example_com_TXT" {
domain =inwx_nameserver.example_com_ns.domain
type = "TXT"
content = "DNS records with terraform"
}
# Using this, all search queries for the subdomain `myproject.example.com`
# (including sub-subdomains: `*.myproject.example.com`) would go to the nameserver of `provider B`
# where another zone for the domain `example.com` exists, that contains all the records for `myproject`
resource "inwx_nameserver_record" "myproject_example_com_NS" {
domain = inwx_nameserver.example_com_ns.domain
name = "myproject.${inwx_nameserver.example_com_ns.domain}"
type = "NS"
content = "ns.providerB.com"
}
It seems you can't add a domain entry on a nameserver directly with the terraform provider, at least it was only possible for me to add dns entries when I add the domain manually in the web UI first.
The
inwx_domain
resource is only useful if the specified domain isn't in use yet and available for registration.Would it be possible to add a new resource to do this? This would be especially useful if you e.g. want to create/prepare dns entries before a domain transfer to INWX. At the moment you need to create the domain manually before being able to use the
inwx_nameserver_record
resource at Nameserver > Nameserver entries