Skip to content

Commit 66022fc

Browse files
authored
Merge pull request #112 from answerdigital/cloudflare-fqdn
Cloudflare records now require FQDN
2 parents a43cc9c + 216587f commit 66022fc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

modules/cloudflare/dns/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The module also simplifies a few boilerplate records at the apex for security pu
3737
| <a name="input_create_zone"></a> [create\_zone](#input\_create\_zone) | Whether to create the zone. Defaults to `true`. | `bool` | `true` | no |
3838
| <a name="input_default_ttl"></a> [default\_ttl](#input\_default\_ttl) | Default TTL for DNS records. Defaults to 1, which means “automatic”. | `number` | `1` | no |
3939
| <a name="input_domain"></a> [domain](#input\_domain) | The top-level domain name to hold the records. | `string` | n/a | yes |
40-
| <a name="input_records"></a> [records](#input\_records) | List of DNS records for the domain.<br/><br/> • `name` - (Optional) The name of the record. Defaults to "@" (i.e. an apex record).<br/> • `ttl` - (Optional) The TTL of the record. Defaults to `default_ttl`.<br/> • `type` - (Required) The record type.<br/> • `content` - (Required) The content of the record.<br/> • `priority` - (Optional) The priority of the record.<br/> • `proxied` - (Optional) Whether to use Cloudflare’s origin protection. Defaults to `false`. | <pre>map(object({<br/> name = optional(string, "@")<br/> ttl = optional(number)<br/> type = string<br/> content = string<br/> priority = optional(number)<br/> proxied = optional(bool, false)<br/> }))</pre> | n/a | yes |
40+
| <a name="input_records"></a> [records](#input\_records) | List of DNS records for the domain.<br/><br/> • `name` - (Optional) The sudomain name (without the domain suffix). Defaults to empty (i.e. an apex record).<br/> • `ttl` - (Optional) The TTL of the record. Defaults to `default_ttl`.<br/> • `type` - (Required) The record type.<br/> • `content` - (Required) The content of the record.<br/> • `priority` - (Optional) The priority of the record.<br/> • `proxied` - (Optional) Whether to use Cloudflare’s origin protection. Defaults to `false`. | <pre>map(object({<br/> name = optional(string)<br/> ttl = optional(number)<br/> type = string<br/> content = string<br/> priority = optional(number)<br/> proxied = optional(bool, false)<br/> }))</pre> | n/a | yes |
4141
| <a name="input_security_contact"></a> [security\_contact](#input\_security\_contact) | Security contact for the domain. Defaults to 'security@DOMAIN', where `DOMAIN` is the top-level domain name. | `string` | `null` | no |
4242
| <a name="input_spf"></a> [spf](#input\_spf) | List of SPF directives for the domain. | `list(string)` | `[]` | no |
4343

modules/cloudflare/dns/dns.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ resource "cloudflare_dns_record" "dns" {
1818
for_each = var.records
1919

2020
zone_id = local.zone_id
21-
name = each.value.name
21+
name = each.value.name != null ? "${each.value.name}.${var.domain}" : var.domain
2222
ttl = each.value.ttl != null ? each.value.ttl : var.default_ttl
2323
type = each.value.type
2424
content = each.value.content
@@ -33,7 +33,7 @@ resource "cloudflare_dns_record" "apex_txt" {
3333
]))
3434

3535
zone_id = local.zone_id
36-
name = "@"
36+
name = var.domain
3737
ttl = var.default_ttl
3838
type = "TXT"
3939
content = each.value
@@ -43,7 +43,7 @@ resource "cloudflare_dns_record" "apex_txt" {
4343
resource "cloudflare_dns_record" "caa" {
4444
for_each = toset(var.caa_issuers)
4545
zone_id = local.zone_id
46-
name = "@"
46+
name = var.domain
4747
ttl = var.default_ttl
4848
type = "CAA"
4949

modules/cloudflare/dns/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ variable "records" {
1818
description = <<EOT
1919
List of DNS records for the domain.
2020
21-
• `name` - (Optional) The name of the record. Defaults to "@" (i.e. an apex record).
21+
• `name` - (Optional) The sudomain name (without the domain suffix). Defaults to empty (i.e. an apex record).
2222
• `ttl` - (Optional) The TTL of the record. Defaults to `default_ttl`.
2323
• `type` - (Required) The record type.
2424
• `content` - (Required) The content of the record.
2525
• `priority` - (Optional) The priority of the record.
2626
• `proxied` - (Optional) Whether to use Cloudflare’s origin protection. Defaults to `false`.
2727
EOT
2828
type = map(object({
29-
name = optional(string, "@")
29+
name = optional(string)
3030
ttl = optional(number)
3131
type = string
3232
content = string

0 commit comments

Comments
 (0)