-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathroute53.tf
More file actions
50 lines (41 loc) · 1.37 KB
/
Copy pathroute53.tf
File metadata and controls
50 lines (41 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
resource "aws_route53_zone" "this" {
count = local.create_hosted_zone ? 1 : 0
name = local.primary_domain
tags = var.tags
}
#############################################
# Validation for the ACM cert
#############################################
resource "aws_route53_record" "acm_records" {
for_each = {
for dvo in aws_acm_certificate.this.domain_validation_options :
dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
}
}
zone_id = try(aws_route53_zone.this[0].zone_id, data.aws_route53_zone.this[0].zone_id)
type = each.value.type
name = each.value.name
records = [each.value.record]
ttl = 60
allow_overwrite = true
provider = aws.default
}
#############################################
# Setup the A record for your custom domain
#############################################
resource "aws_route53_record" "static_site_a_record" {
count = length(var.domains)
zone_id = try(aws_route53_zone.this[0].zone_id, data.aws_route53_zone.this[0].zone_id)
type = "A"
name = var.domains[count.index]
alias {
name = aws_cloudfront_distribution.this.domain_name
zone_id = aws_cloudfront_distribution.this.hosted_zone_id
evaluate_target_health = false
}
allow_overwrite = true
provider = aws.default
}