How do I make mx, txt records with terraform ?
Hi all,
I tried in many shape for a make txt and mx records but, i get the same error again and again.
the following code its a part of my code.
resource "linode_domain_record" "mx_04" {
domain_id = linode_domain.mydomain.id
priority = 10
record_type = "MX"
ttl_sec = 300
target = var.domain
target = format("mail.%s",var.domain)
}
this its the error.
Error: name is required for non-SRV records
on 02_dns.tf line 45, in resource "linode_domain_record" "mx_04":
45: resource "linode_domain_record" "mx_04" {
so i decided try in another direction with the following link https://www.linode.com/docs/applications/configuration-management/terraform/import-existing-infrastructure-to-terraform/#import-your-domain-record-to-terraform
this is the sample config for my actual infrastructure
linode_domain_record.warbof_mx:
resource "linode_domain_record" "example_mx" {
domain_id = 622323
id = "1333331233"
port = 0
priority = 10
record_type = "MX"
target = "mail.example.org"
ttl_sec = 300
weight = 0
}
linode_domain_record.example_spf:
resource "linode_domain_record" "example_spf" {
domain_id = 622323
id = "1333331234"
port = 0
priority = 0
record_type = "TXT"
target = "v=spf1 a mx ip4:111.111.111.111 ~all"
ttl_sec = 300
weight = 0
}
i replace domain_id and i remove the actual id, for make a new instance.
domain_id = linode_domain.mydomain.id
but when i apply with terraform i get the same error again. Actually in the documentation in terraform and git, is not clearly with all options.
my actual version of terraform is 12 and linode provider is deployed by git (i was probe current version and olders, but i have the same results).
if you any suggestions, let me know.
1 Reply
Hi! I want to give you some additional resources that I think might be able to help you out. Terraform has docs of their own that are designed to be used with Terraform/Linode instances.
These are nice because they give examples of what your configuration should look like:
Just make sure you're using your specific information as opposed to the examples given in the guides (i.e. example.com).