-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute53.tf
75 lines (60 loc) · 2.12 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#################################################
# Route53 - DNS Settings
#################################################
data "aws_route53_zone" "public" {
name = local.app_domain_root
}
resource "aws_route53_record" "sub" {
count = local.use_subdom ? 1 : 0
type = "A"
zone_id = data.aws_route53_zone.public.zone_id
name = local.app_domain
alias {
zone_id = aws_cloudfront_distribution.app.hosted_zone_id
name = aws_cloudfront_distribution.app.domain_name
evaluate_target_health = false
}
}
resource "aws_route53_record" "root" {
count = local.use_subdom ? 0 : 1
type = "A"
zone_id = data.aws_route53_zone.public.zone_id
name = local.app_domain
alias {
zone_id = aws_cloudfront_distribution.app.hosted_zone_id
name = aws_cloudfront_distribution.app.domain_name
evaluate_target_health = false
}
}
resource "aws_route53_record" "web_apps" {
for_each = local.web_apps
type = "A"
zone_id = data.aws_route53_zone.public.zone_id
name = "${each.key}.${local.app_domain}"
alias {
zone_id = aws_cloudfront_distribution.app.hosted_zone_id
name = aws_cloudfront_distribution.app.domain_name
evaluate_target_health = false
}
}
resource "aws_route53_record" "auth" {
count = local.is_anon ? 0 : 1
type = "A"
zone_id = data.aws_route53_zone.public.zone_id
name = aws_cognito_user_pool_domain.app[0].domain
alias {
zone_id = "Z2FDTNDATAQYW2" # This zone_id is static for Cognito
name = aws_cognito_user_pool_domain.app[0].cloudfront_distribution_arn
evaluate_target_health = false
}
}
resource "aws_route53_record" "api" {
type = "A"
zone_id = data.aws_route53_zone.public.zone_id
name = aws_apigatewayv2_domain_name.app.domain_name
alias {
zone_id = aws_apigatewayv2_domain_name.app.domain_name_configuration[0].hosted_zone_id
name = aws_apigatewayv2_domain_name.app.domain_name_configuration[0].target_domain_name
evaluate_target_health = false
}
}