This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
forked from enchant97/hasty-paste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
route53.tf
83 lines (73 loc) · 3.17 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
76
77
78
79
80
81
82
83
# ## Create Route 53 Hosted Zone for the domain of our service including NS records in the top level domain
# resource "aws_route53_zone" "service" {
# name = var.domain_name
# }
# resource "aws_route53_record" "service" {
# zone_id = var.tld_zone_id
# name = var.domain_name
# type = "NS"
# ttl = 300
# records = [
# aws_route53_zone.service.name_servers[0],
# aws_route53_zone.service.name_servers[1],
# aws_route53_zone.service.name_servers[2],
# aws_route53_zone.service.name_servers[3]
# ]
# }
# ## Certificate for Application Load Balancer including validation via CNAME record
# resource "aws_acm_certificate" "alb_certificate" {
# domain_name = var.domain_name
# validation_method = "DNS"
# subject_alternative_names = ["*.${var.domain_name}"]
# }
# resource "aws_acm_certificate_validation" "alb_certificate" {
# certificate_arn = aws_acm_certificate.alb_certificate.arn
# validation_record_fqdns = [aws_route53_record.generic_certificate_validation.fqdn]
# }
# ## Certificate for CloudFront Distribution in region us.east-1
# resource "aws_acm_certificate" "cloudfront_certificate" {
# provider = aws.us_east_1
# domain_name = var.domain_name
# validation_method = "DNS"
# subject_alternative_names = ["*.${var.domain_name}"]
# }
# resource "aws_acm_certificate_validation" "cloudfront_certificate" {
# provider = aws.us_east_1
# certificate_arn = aws_acm_certificate.cloudfront_certificate.arn
# validation_record_fqdns = [aws_route53_record.generic_certificate_validation.fqdn]
# }
# ## We only need one record for the DNS validation for both certificates, as records are the same for all regions
# resource "aws_route53_record" "generic_certificate_validation" {
# name = tolist(aws_acm_certificate.alb_certificate.domain_validation_options)[0].resource_record_name
# type = tolist(aws_acm_certificate.alb_certificate.domain_validation_options)[0].resource_record_type
# zone_id = aws_route53_zone.service.id
# records = [tolist(aws_acm_certificate.alb_certificate.domain_validation_options)[0].resource_record_value]
# ttl = 300
# }
# ## Hosted zone for development subdomain of our service
# resource "aws_route53_zone" "environment" {
# name = "${var.environment}.${var.domain_name}"
# }
# resource "aws_route53_record" "environment" {
# zone_id = aws_route53_zone.service.id
# name = "${var.environment}.${var.domain_name}"
# type = "NS"
# ttl = 300
# records = [
# aws_route53_zone.environment.name_servers[0],
# aws_route53_zone.environment.name_servers[1],
# aws_route53_zone.environment.name_servers[2],
# aws_route53_zone.environment.name_servers[3]
# ]
# }
# ## Point A record to CloudFront distribution
# resource "aws_route53_record" "service_record" {
# name = "${var.environment}.${var.domain_name}"
# type = "A"
# zone_id = aws_route53_zone.environment.id
# alias {
# name = aws_cloudfront_distribution.default.domain_name
# zone_id = aws_cloudfront_distribution.default.hosted_zone_id
# evaluate_target_health = false
# }
# }