-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelbv2_splunk.tf
153 lines (128 loc) · 3.82 KB
/
elbv2_splunk.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
resource "aws_lb" "splunk_alb" {
name = "splunk-alb"
load_balancer_type = "application"
security_groups = [
aws_security_group.splunk_alb.id
]
subnets = [
module.vpc.subnet_public1,
module.vpc.subnet_public2,
module.vpc.subnet_public3
]
}
resource "aws_lb_listener" "splunk_console_http" {
load_balancer_arn = aws_lb.splunk_alb.arn
port = 80
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.splunk_alb_console.arn
}
}
resource "aws_lb_listener" "splunk_hec" {
load_balancer_arn = aws_lb.splunk_alb.arn
port = 8088
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.splunk_alb_hec.arn
}
}
resource "aws_lb_target_group" "splunk_alb_hec" {
vpc_id = module.vpc.vpc_id
name = "splunk-tg-hec"
port = 8088
protocol = "HTTP"
target_type = "ip"
deregistration_delay = 0
health_check {
path = "/services/collector/health"
healthy_threshold = 2
interval = 5
timeout = 2
}
}
resource "aws_lb_target_group" "splunk_alb_console" {
vpc_id = module.vpc.vpc_id
name = "splunk-tg-console"
port = 8000
protocol = "HTTP"
target_type = "ip"
deregistration_delay = 0
health_check {
matcher = "200-399"
healthy_threshold = 2
interval = 5
timeout = 2
}
}
resource "aws_security_group" "splunk_alb" {
vpc_id = module.vpc.vpc_id
name = "splunk-alb"
}
resource "aws_security_group_rule" "splunk_alb_egress_all" {
security_group_id = aws_security_group.splunk_alb.id
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
resource "aws_security_group_rule" "splunk_alb_ingress_80_admin" {
security_group_id = aws_security_group.splunk_alb.id
type = "ingress"
protocol = "tcp"
from_port = 80
to_port = 80
cidr_blocks = [var.admin_cidr]
}
resource "aws_security_group_rule" "splunk_alb_ingress_8088_admin" {
security_group_id = aws_security_group.splunk_alb.id
type = "ingress"
protocol = "tcp"
from_port = 8088
to_port = 8088
cidr_blocks = [var.admin_cidr]
}
resource "aws_security_group_rule" "splunk_alb_ingress_hec_vpc" {
type = "ingress"
protocol = "tcp"
from_port = 8088
to_port = 8088
cidr_blocks = ["10.0.0.0/16"]
security_group_id = aws_security_group.splunk_alb.id
}
resource "aws_security_group_rule" "splunk_alb_ingress_hec_cloudfront" {
security_group_id = aws_security_group.splunk_alb.id
type = "ingress"
protocol = "tcp"
# hack - ideally there's be a rule for 80-80 and 8080-8080 but was hitting max Rules per SG
from_port = 80
to_port = 8088
prefix_list_ids = [data.aws_ec2_managed_prefix_list.cloudfront_origin_facing.id]
}
#resource "aws_security_group_rule" "splunk_alb_ingress_console_all" {
# security_group_id = aws_security_group.splunk_alb.id
# type = "ingress"
# protocol = "tcp"
# from_port = 80
# to_port = 80
#
# cidr_blocks = ["0.0.0.0/0"]
#}
#
#resource "aws_security_group_rule" "splunk_alb_ingress_hec_all" {
# security_group_id = aws_security_group.splunk_alb.id
# type = "ingress"
# protocol = "tcp"
# from_port = 8080
# to_port = 8080
#
# cidr_blocks = ["0.0.0.0/0"]
#}
data "aws_ec2_managed_prefix_list" "cloudfront_origin_facing" {
filter {
name = "prefix-list-name"
values = ["com.amazonaws.global.cloudfront.origin-facing"]
}
}