-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathroute53.tf
58 lines (48 loc) · 1.57 KB
/
route53.tf
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
51
52
53
54
55
56
57
58
locals {
route53_zone_id = var.use_existing_route53_zone ? data.aws_route53_zone.default[0].zone_id : aws_route53_zone.default[0].zone_id
}
data "aws_route53_zone" "default" {
count = var.use_existing_route53_zone ? 1 : 0
name = var.fqdn
}
resource "aws_route53_zone" "default" {
count = var.use_existing_route53_zone ? 0 : 1
name = var.fqdn
}
resource "aws_route53_record" "default" {
zone_id = local.route53_zone_id
name = var.fqdn
type = "A"
alias {
name = aws_cloudfront_distribution.s3_distribution.domain_name
zone_id = aws_cloudfront_distribution.s3_distribution.hosted_zone_id
evaluate_target_health = false
}
}
resource "aws_route53_record" "aliases" {
count = length(var.aliases)
zone_id = local.route53_zone_id
name = var.aliases[count.index]
type = "A"
alias {
name = aws_cloudfront_distribution.s3_distribution.domain_name
zone_id = aws_cloudfront_distribution.s3_distribution.hosted_zone_id
evaluate_target_health = false
}
}
resource "aws_route53_record" "validation" {
for_each = {
for dvo in aws_acm_certificate.default.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
zone_id = local.route53_zone_id
}
}
allow_overwrite = true
name = each.value.name
records = [each.value.record]
type = each.value.type
zone_id = each.value.zone_id
ttl = 60
}