Skip to content

Commit 2e3ca6a

Browse files
add support for aaaa records (#5)
* add support for aaaa records * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 88e8c75 commit 2e3ca6a

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-36
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ No modules.
2929
| [aws_acm_certificate_validation.records_wr](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate_validation) | resource |
3030
| [aws_cloudfront_distribution.records_wr](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution) | resource |
3131
| [aws_route53_record.records_a](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
32+
| [aws_route53_record.records_aaaa](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
3233
| [aws_route53_record.records_caa](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
3334
| [aws_route53_record.records_cname](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
3435
| [aws_route53_record.records_mx](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
@@ -45,13 +46,14 @@ No modules.
4546
| Name | Description | Type | Default | Required |
4647
|------|-------------|------|---------|:--------:|
4748
| <a name="input_primary_domain"></a> [primary\_domain](#input\_primary\_domain) | Route53 Primary domain | `any` | n/a | yes |
48-
| <a name="input_records_a"></a> [records\_a](#input\_records\_a) | Map of A records separate by comma (,) | `map` | `{}` | no |
49-
| <a name="input_records_caa"></a> [records\_caa](#input\_records\_caa) | Map of CAA records separate by comma (,) | `map` | `{}` | no |
50-
| <a name="input_records_cname"></a> [records\_cname](#input\_records\_cname) | Map of CNAME records separate by comma (,) | `map` | `{}` | no |
51-
| <a name="input_records_mx"></a> [records\_mx](#input\_records\_mx) | Map of MX records separate by comma (,) | `map` | `{}` | no |
52-
| <a name="input_records_ns"></a> [records\_ns](#input\_records\_ns) | Map of NS records separate by comma (,) | `map` | `{}` | no |
53-
| <a name="input_records_txt"></a> [records\_txt](#input\_records\_txt) | Map of TXT records separate by comma (,) | `map` | `{}` | no |
54-
| <a name="input_records_wr"></a> [records\_wr](#input\_records\_wr) | Map of redirect records | `map` | `{}` | no |
49+
| <a name="input_records_a"></a> [records\_a](#input\_records\_a) | Map of A records separate by comma (,) | `map(any)` | `{}` | no |
50+
| <a name="input_records_aaaa"></a> [records\_aaaa](#input\_records\_aaaa) | Map of AAAA records separate by comma (,) | `map(any)` | `{}` | no |
51+
| <a name="input_records_caa"></a> [records\_caa](#input\_records\_caa) | Map of CAA records separate by comma (,) | `map(any)` | `{}` | no |
52+
| <a name="input_records_cname"></a> [records\_cname](#input\_records\_cname) | Map of CNAME records separate by comma (,) | `map(any)` | `{}` | no |
53+
| <a name="input_records_mx"></a> [records\_mx](#input\_records\_mx) | Map of MX records separate by comma (,) | `map(any)` | `{}` | no |
54+
| <a name="input_records_ns"></a> [records\_ns](#input\_records\_ns) | Map of NS records separate by comma (,) | `map(any)` | `{}` | no |
55+
| <a name="input_records_txt"></a> [records\_txt](#input\_records\_txt) | Map of TXT records separate by comma (,) | `map(any)` | `{}` | no |
56+
| <a name="input_records_wr"></a> [records\_wr](#input\_records\_wr) | Map of redirect records | `map(any)` | `{}` | no |
5557
| <a name="input_ttl"></a> [ttl](#input\_ttl) | Default TTL for All records | `number` | `"3600"` | no |
5658
| <a name="input_ttl_acm"></a> [ttl\_acm](#input\_ttl\_acm) | Default TTL for acm records | `number` | `"60"` | no |
5759
| <a name="input_ttl_ns"></a> [ttl\_ns](#input\_ttl\_ns) | Default TTL for ns records | `number` | `"172800"` | no |
@@ -82,6 +84,10 @@ module "example-com" {
8284
"example.com" = ["12.23.45.56"]
8385
}
8486
87+
records_aaaa = {
88+
"example.com" = ["::ffff:c17:2d38"]
89+
}
90+
8591
records_caa = {
8692
"example.com" = ["0 issue \"letsencrypt.org\""]
8793
}
@@ -121,7 +127,7 @@ Supported record types as follows:
121127
| Record type | Supported |
122128
| ------------- | ---------- |
123129
| A | YES |
124-
| AAAA | NO |
130+
| AAAA | YES |
125131
| CAA | YES |
126132
| CNAME | YES |
127133
| LOC | NO |

main.tf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_route53_zone" "this" {
2-
name = var.primary_domain
2+
name = var.primary_domain
33
}
44

55
resource "aws_route53_record" "records_a" {
@@ -12,6 +12,16 @@ resource "aws_route53_record" "records_a" {
1212
records = each.value
1313
}
1414

15+
resource "aws_route53_record" "records_aaaa" {
16+
depends_on = [aws_route53_zone.this]
17+
for_each = var.records_aaaa
18+
zone_id = aws_route53_zone.this.zone_id
19+
name = each.key
20+
type = "AAAA"
21+
ttl = var.ttl
22+
records = each.value
23+
}
24+
1525
resource "aws_route53_record" "records_caa" {
1626
depends_on = [aws_route53_zone.this]
1727
for_each = var.records_caa
@@ -40,8 +50,8 @@ resource "aws_route53_record" "records_wr_validation" {
4050
depends_on = [aws_route53_zone.this]
4151
for_each = {
4252
for dvo in flatten([
43-
for cert in aws_acm_certificate.records_wr: cert.domain_validation_options
44-
]): dvo.domain_name => {
53+
for cert in aws_acm_certificate.records_wr : cert.domain_validation_options
54+
]) : dvo.domain_name => {
4555
name = dvo.resource_record_name
4656
record = dvo.resource_record_value
4757
type = dvo.resource_record_type

variables.tf

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,68 @@ variable "primary_domain" {
33
type = any
44
}
55

6-
variable "ttl" {
7-
description = "Default TTL for All records"
8-
type = number
9-
default = "3600"
10-
}
11-
12-
variable "ttl_acm" {
13-
description = "Default TTL for acm records"
14-
type = number
15-
default = "60"
16-
}
17-
18-
variable "ttl_ns" {
19-
description = "Default TTL for ns records"
20-
type = number
21-
default = "172800"
22-
}
23-
246
variable "records_a" {
25-
type = map
7+
type = map(any)
268
description = "Map of A records separate by comma (,)"
279
default = {}
2810
}
2911

12+
variable "records_aaaa" {
13+
type = map(any)
14+
description = "Map of AAAA records separate by comma (,)"
15+
default = {}
16+
}
17+
3018
variable "records_caa" {
31-
type = map
19+
type = map(any)
3220
description = "Map of CAA records separate by comma (,)"
3321
default = {}
3422
}
3523

3624
variable "records_cname" {
37-
type = map
25+
type = map(any)
3826
description = "Map of CNAME records separate by comma (,)"
3927
default = {}
4028
}
4129

4230
variable "records_mx" {
43-
type = map
31+
type = map(any)
4432
description = "Map of MX records separate by comma (,)"
4533
default = {}
4634
}
4735

4836
variable "records_txt" {
49-
type = map
37+
type = map(any)
5038
description = "Map of TXT records separate by comma (,)"
5139
default = {}
5240
}
5341

5442
variable "records_ns" {
55-
type = map
43+
type = map(any)
5644
description = "Map of NS records separate by comma (,)"
5745
default = {}
5846
}
5947

6048
variable "records_wr" {
61-
type = map
49+
type = map(any)
6250
description = "Map of redirect records"
6351
default = {}
6452
}
53+
54+
variable "ttl" {
55+
description = "Default TTL for All records"
56+
type = number
57+
default = "3600"
58+
}
59+
60+
variable "ttl_acm" {
61+
description = "Default TTL for acm records"
62+
type = number
63+
default = "60"
64+
}
65+
66+
variable "ttl_ns" {
67+
description = "Default TTL for ns records"
68+
type = number
69+
default = "172800"
70+
}

0 commit comments

Comments
 (0)