Skip to content

Commit 62f5f61

Browse files
authored
Let acm module create validation records for us (#18)
* Let acm module create validation records for us * Add moved blocks
1 parent 25b8c87 commit 62f5f61

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

main.tf

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,15 @@ module "acm" {
44

55
create_certificate = var.domain_name != "" ? true : false
66

7-
domain_name = var.dns_subdomain
8-
subject_alternative_names = var.subject_alternative_names
9-
10-
validate_certificate = false
11-
validation_method = "DNS"
12-
13-
tags = var.tags
14-
}
7+
validation_method = "DNS"
158

16-
resource "aws_route53_record" "validation" {
17-
depends_on = [module.acm]
9+
domain_name = var.dns_subdomain
10+
zone_id = data.aws_route53_zone.selected[0].zone_id
1811

19-
count = length(local.hostnames)
20-
21-
zone_id = local.validation_zone_mapping[module.acm.acm_certificate_domain_validation_options[count.index]["domain_name"]]
22-
name = module.acm.acm_certificate_domain_validation_options[count.index]["resource_record_name"]
23-
type = module.acm.acm_certificate_domain_validation_options[count.index]["resource_record_type"]
24-
records = [module.acm.acm_certificate_domain_validation_options[count.index]["resource_record_value"]]
25-
ttl = 60
26-
allow_overwrite = var.validation_allow_overwrite_records
27-
}
12+
subject_alternative_names = var.subject_alternative_names
13+
zones = local.validation_zone_mapping
2814

29-
resource "aws_acm_certificate_validation" "this" {
30-
certificate_arn = module.acm.acm_certificate_arn
31-
validation_record_fqdns = aws_route53_record.validation.*.fqdn
15+
tags = var.tags
3216
}
3317

3418
module "application" {
@@ -48,7 +32,7 @@ module "environment" {
4832

4933
depends_on = [
5034
aws_elastic_beanstalk_application_version.default,
51-
aws_acm_certificate_validation.this,
35+
module.acm,
5236
]
5337

5438
name = var.application_name

moved.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ moved {
77
from = module.elastic_beanstalk_environment
88
to = module.environment
99
}
10+
11+
moved {
12+
from = aws_route53_record.validation
13+
to = module.acm.aws_route53_record.validation
14+
}
15+
16+
moved {
17+
from = aws_acm_certificate_validation.this
18+
to = module.acm.aws_acm_certificate_validation.this[0]
19+
}

0 commit comments

Comments
 (0)