-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path008_route53.tf
More file actions
135 lines (102 loc) · 4.01 KB
/
Copy path008_route53.tf
File metadata and controls
135 lines (102 loc) · 4.01 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
## ------------------------------------------------------------------------------------
## 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
## ------------------------------------------------------------------------------------
# Badly named resource -- this is the record need to reach SP via ALB.
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
}
}
# Badly named resource -- this is the record need to reach SP directly via EC2.
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 = var.flag_studio_enable_path_routing ? module.connection_strings.tower_connect_dns : module.connection_strings.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 = var.flag_studio_enable_path_routing ? module.connection_strings.tower_connect_dns : module.connection_strings.tower_connect_wildcard_dns
type = "A"
ttl = "5"
records = [local.dns_instance_ip]
}
# Tower Connect SSH — NLB-only path. Resolves connect-ssh.<tower_server_url> to the NLB
# created in 007_load_balancer.tf for TCP passthrough on port 2222.
resource "aws_route53_record" "nlb_ssh" {
count = local.dns_create_alb_record == true && var.flag_enable_data_studio_ssh == true ? 1 : 0
zone_id = local.dns_zone_id
name = module.connection_strings.tower_connect_ssh_dns
type = "A"
alias {
name = aws_lb.nlb_ssh[0].dns_name
zone_id = aws_lb.nlb_ssh[0].zone_id
evaluate_target_health = true
}
}
resource "aws_route53_record" "alb_wave" {
count = local.dns_create_alb_record == true && var.flag_use_wave_lite == true ? 1 : 0
zone_id = local.dns_zone_id
name = module.connection_strings.tower_wave_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_wave" {
count = local.dns_create_ec2_record == true ? 1 : 0
zone_id = local.dns_zone_id
# name = local.tower_connect_dns
# name = module.connection_strings.tower_connect_wildcard_dns
name = module.connection_strings.tower_wave_dns
type = "A"
ttl = "5"
records = [local.dns_instance_ip]
}