提交 1d0c13b9 编写于 作者: F freesky-edward

Add dns records support

上级 6b093ca8
resource "huaweicloud_dns_ptrrecord_v2" "this" {
count = "${length(var.ptrs)}"
name = "${lookup(var.ptrs[count.index], "domain", null)}"
description = "${lookup(var.ptrs[count.index], "description", "ptr")}"
floatingip_id = "${lookup(var.ptrs[count.index], "ip", null)}"
ttl = "${lookup(var.ptrs[count.index], "ttl", 3000)}"
}
resource "huaweicloud_dns_zone_v2" "this" {
name = "${var.domain}"
email = "${var.email}"
description = "${var.description}"
ttl = "${var.ttl}"
zone_type = "${var.type}"
}
resource "huaweicloud_dns_recordset_v2" "this" {
count = "${length(var.records)}"
zone_id = "${huaweicloud_dns_zone_v2.this.id}"
name = "${lookup(var.records[count.index], "domain", null)}"
description = "${lookup(var.records[count.index], "description", "")}"
ttl = "${lookup(var.records[count.index], "ttl", 3000)}"
type = "${lookup(var.records[count.index], "type", null)}"
records = ["${lookup(var.records[count.index], "value", null)}"]
}
variable "domain" {
description = "The domain name of this dns"
}
variable "email" {
description = "The manager's email"
}
variable "ttl" {
description = "The ttl time"
default = 3000
}
variable "type" {
description = "The DNS type, the value would be public or private"
default = "public"
}
variable "description" {
description = "The dns description string"
default = ""
}
variable "records" {
type = list(map(string))
description = "List of each dns records"
default = []
}
variable "ptrs" {
type = list(map(string))
description = "List of ptr records"
default = []
}
......@@ -122,4 +122,40 @@ module "nat" {
]
}
module "dns" {
source = "./dns"
domain = "openeuler.org"
email = "freesky.edward@gmail.com"
records = [
{
domain = "mail"
type = "A"
value = "${split(",", module.internet.this_eip_ids)[1]}"
},
{
domain = "mailweb"
type = "A"
value = "${split(",", module.internet.this_eip_ids)[2]}"
},
{
domain = "@"
type = "MX"
value = "mail.openeuler.org"
},
{
domain = "@"
type = "TXT"
value = "v=spf1 a mx ip4:${split(",", module.internet.this_eip_ids)[0]} ~all"
}
]
ptrs = [
{
domain = "openeuler.org"
ip = "${split(",", module.internet.this_eip_ids)[0]}"
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册