-
Notifications
You must be signed in to change notification settings - Fork 1
/
splunk_alb.tf
124 lines (105 loc) · 3.02 KB
/
splunk_alb.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
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
# Load Balancer
resource "aws_lb" "splunk_ent" {
load_balancer_type = "application"
name = "splunk-lb-${random_id.random.hex}" # Only allows hyphens
internal = "false"
security_groups = [aws_security_group.splunk_ent.id]
subnets = [aws_subnet.splunk_subnet_a.id,aws_subnet.splunk_subnet_b.id]
tags = merge(
local.common_tags,
{
"Name" = "splunk-lb-${random_id.random.hex}"
}
)
}
data "aws_acm_certificate" "splunk_ent" {
domain = var.splunk_alb_acm_matcher
statuses = ["ISSUED"]
most_recent = true
}
data "aws_route53_zone" "selected" {
name = var.splunk_alb_r53_matcher
}
resource "aws_route53_record" "splunk_ent" {
zone_id = data.aws_route53_zone.selected.zone_id
name = var.splunk_hostname
type = "CNAME"
ttl = "30"
records = [aws_lb.splunk_ent.dns_name]
}
#
# Splunk Web
#
resource "aws_lb_target_group" "splunk_ent" {
name = "splunk-lb-tg-${random_id.random.hex}" # Only allows hyphens
vpc_id = aws_vpc.splunk_vpc.id
port = "8000"
protocol = "HTTPS"
depends_on = [aws_lb.splunk_ent]
lifecycle {
create_before_destroy = true
}
tags = merge(
local.common_tags,
{
"Name" = "splunk-lb-tg-${random_id.random.hex}"
}
)
}
resource "aws_lb_listener" "splunk_ent" {
load_balancer_arn = aws_lb.splunk_ent.arn
port = "443"
protocol = "HTTPS"
certificate_arn = data.aws_acm_certificate.splunk_ent.arn
default_action {
target_group_arn = aws_lb_target_group.splunk_ent.id
type = "forward"
}
}
resource "aws_lb_listener_certificate" "splunk_ent" {
listener_arn = aws_lb_listener.splunk_ent.arn
certificate_arn = data.aws_acm_certificate.splunk_ent.arn
}
resource "aws_lb_target_group_attachment" "splunk_ent" {
target_group_arn = aws_lb_target_group.splunk_ent.arn
target_id = aws_instance.splunk_ent.id
port = 8000
}
#
# Splunk HEC
#
resource "aws_lb_target_group" "splunk_ent_hec" {
name = "splunk-lb-tg-hec-${random_id.random.hex}" # Only allows hyphens
vpc_id = aws_vpc.splunk_vpc.id
port = "8088"
protocol = "HTTPS"
depends_on = [aws_lb.splunk_ent]
lifecycle {
create_before_destroy = true
}
tags = merge(
local.common_tags,
{
"Name" = "splunk-lb-tg-hec-${random_id.random.hex}"
}
)
}
resource "aws_lb_listener" "splunk_ent_hec" {
load_balancer_arn = aws_lb.splunk_ent.arn
port = "8088"
protocol = "HTTPS"
certificate_arn = data.aws_acm_certificate.splunk_ent.arn
default_action {
target_group_arn = aws_lb_target_group.splunk_ent_hec.id
type = "forward"
}
}
resource "aws_lb_listener_certificate" "splunk_ent_hec" {
listener_arn = aws_lb_listener.splunk_ent_hec.arn
certificate_arn = data.aws_acm_certificate.splunk_ent.arn
}
resource "aws_lb_target_group_attachment" "splunk_ent_hec" {
target_group_arn = aws_lb_target_group.splunk_ent_hec.arn
target_id = aws_instance.splunk_ent.id
port = 8088
}