-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path008_route53.tf
90 lines (68 loc) · 2.46 KB
/
008_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
84
85
86
87
88
89
90
## ------------------------------------------------------------------------------------
## Hosted Zone retrieval
## ------------------------------------------------------------------------------------
data "aws_route53_zone" "public" {
count = var.flag_use_existing_route53_public_zone == true ? 1 : 0
name = var.existing_route53_public_zone_name
}
data "aws_route53_zone" "private" {
count = var.flag_use_existing_route53_private_zone == true ? 1 : 0
name = var.existing_route53_private_zone_name
vpc_id = local.vpc_id
private_zone = true
}
## ------------------------------------------------------------------------------------
## Hosted Zone Generation
## ------------------------------------------------------------------------------------
resource "aws_route53_zone" "private" {
count = var.flag_create_route53_private_zone == true ? 1 : 0
name = var.new_route53_private_zone_name
vpc {
vpc_id = local.vpc_id
}
}
## ------------------------------------------------------------------------------------
## Route53 A Record Generation
## Note: If no Route53 records are generated, an entry will be added to the EC2 hosts file
## ------------------------------------------------------------------------------------
resource "aws_route53_record" "alb" {
count = local.dns_create_alb_record == true ? 1 : 0
zone_id = local.dns_zone_id
name = var.tower_server_url
type = "A"
alias {
name = module.alb[0].lb_dns_name
zone_id = module.alb[0].lb_zone_id
evaluate_target_health = true
}
}
resource "aws_route53_record" "ec2" {
count = local.dns_create_ec2_record == true ? 1 : 0
zone_id = local.dns_zone_id
name = var.tower_server_url
type = "A"
ttl = "5"
records = [local.dns_instance_ip]
}
# Tower Connect
resource "aws_route53_record" "alb_connect" {
count = local.dns_create_alb_record == true ? 1 : 0
zone_id = local.dns_zone_id
# name = local.tower_connect_dns
name = local.tower_connect_wildcard_dns
type = "A"
alias {
name = module.alb[0].lb_dns_name
zone_id = module.alb[0].lb_zone_id
evaluate_target_health = true
}
}
resource "aws_route53_record" "ec2_connect" {
count = local.dns_create_ec2_record == true ? 1 : 0
zone_id = local.dns_zone_id
# name = local.tower_connect_dns
name = local.tower_connect_wildcard_dns
type = "A"
ttl = "5"
records = [local.dns_instance_ip]
}