Skip to content

Commit 5713a7c

Browse files
committed
Adding conditional validation creation
1 parent e3608ae commit 5713a7c

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Used to create a DNS verified ACM certificate by R53 Zone name
2727
|------|-------------|------|---------|:--------:|
2828
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | The domain name to be used for the certificate | `string` | n/a | yes |
2929
| <a name="input_r53_zone_id"></a> [r53\_zone\_id](#input\_r53\_zone\_id) | Parent zone\_id the certificate should be created for | `string` | n/a | yes |
30+
| <a name="input_create_validation_records"></a> [create\_validation\_records](#input\_create\_validation\_records) | Should this module auto-create the needed ACM validation records? | `bool` | `true` | no |
3031
| <a name="input_subject_alternative_names"></a> [subject\_alternative\_names](#input\_subject\_alternative\_names) | List of SANs to include on the certificate, changing this after create forces a re-create | `list(string)` | `[]` | no |
3132
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags to provide to created resources | `map(string)` | `{}` | no |
3233
| <a name="input_ttl"></a> [ttl](#input\_ttl) | TTL to use for R53 verification records, defaults to a short time to allow quick re-create if needed | `number` | `60` | no |
@@ -38,4 +39,5 @@ Used to create a DNS verified ACM certificate by R53 Zone name
3839
| <a name="output_cert_arn"></a> [cert\_arn](#output\_cert\_arn) | n/a |
3940
| <a name="output_cert_status"></a> [cert\_status](#output\_cert\_status) | n/a |
4041
| <a name="output_domain_name"></a> [domain\_name](#output\_domain\_name) | n/a |
42+
| <a name="output_validation_records"></a> [validation\_records](#output\_validation\_records) | n/a |
4143
<!-- END_TF_DOCS -->

main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ resource "aws_acm_certificate" "this" {
1616
}
1717

1818
resource "aws_route53_record" "this" {
19-
for_each = {
19+
for_each = var.create_validation_records ? {
2020
for dvo in aws_acm_certificate.this.domain_validation_options : dvo.domain_name => {
2121
name = dvo.resource_record_name
2222
record = dvo.resource_record_value
2323
type = dvo.resource_record_type
2424
}
25-
}
25+
} : {}
2626

2727
allow_overwrite = true
2828
name = each.value.name
@@ -37,6 +37,8 @@ resource "aws_route53_record" "this" {
3737
}
3838

3939
resource "aws_acm_certificate_validation" "this" {
40+
for_each = var.create_validation_records ? toset(["enable"]) : toset([])
41+
4042
certificate_arn = aws_acm_certificate.this.arn
4143
validation_record_fqdns = [for record in aws_route53_record.this : record.fqdn]
4244

output.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@ output "cert_status" {
88

99
output "domain_name" {
1010
value = aws_acm_certificate.this.domain_name
11+
}
12+
13+
output "validation_records" {
14+
value = {
15+
for dvo in aws_acm_certificate.this.domain_validation_options : dvo.domain_name => {
16+
name = dvo.resource_record_name
17+
record = dvo.resource_record_value
18+
type = dvo.resource_record_type
19+
}
20+
}
1121
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ variable "ttl" {
2525
type = number
2626
default = 60
2727
}
28+
29+
variable "create_validation_records" {
30+
description = "Should this module auto-create the needed ACM validation records?"
31+
type = bool
32+
default = true
33+
}

0 commit comments

Comments
 (0)