Skip to content

Commit 62f7efa

Browse files
committed
feat(google_certificate_map): Add ACME challenge check
1 parent 3a72545 commit 62f7efa

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • google_certificate_manager_certificate_map
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
locals {
2+
acme_records = { for v in flatten([ for ik, iv in google_certificate_manager_dns_authorization.default : iv.dns_resource_record ]) : v.name => v.data }
3+
}
4+
5+
data "dns_cname_record_set" "acme" {
6+
# for_each = { for k, v in google_certificate_manager_dns_authorization.default : k => v.dns_resource_record}
7+
for_each = local.acme_records
8+
9+
host = each.value
10+
}
11+
12+
check "acme" {
13+
assert {
14+
condition = alltrue([
15+
for k, v in data.dns_cname_record_set.acme : v.cname == local.acme_records[k]
16+
])
17+
error_message = <<-EOT
18+
Some ACME challenge records are missing or incorrect:
19+
${join("\n", [
20+
for k, v in data.dns_cname_record_set.acme : format("CNAME %s %s != %s", v.host, v.cname, local.acme_records[k]) if v.cname != local.acme_records[k]
21+
])}
22+
EOT
23+
}
24+
}

0 commit comments

Comments
 (0)