-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
58 lines (42 loc) · 1.08 KB
/
main.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
# Security Group
resource "aws_security_group" "this" {
vpc_id = var.vpc.id
name = "lb-${var.name}"
description = "LB: ${var.name}"
tags = merge({
Name = "LB: ${var.name}"
}, var.default_tags, var.security_group_tags)
lifecycle {
create_before_destroy = true
}
}
resource "aws_security_group_rule" "egress" {
security_group_id = aws_security_group.this.id
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
protocol = "-1"
from_port = 0
to_port = 0
lifecycle {
create_before_destroy = true
}
}
# ALB
resource "aws_lb" "this" {
name = var.name
load_balancer_type = "application"
drop_invalid_header_fields = var.drop_invalid_header_fields
internal = true
subnets = var.subnets[*].id
security_groups = [aws_security_group.this.id]
tags = merge(var.default_tags, var.lb_tags)
}
resource "aws_lb_listener" "this" {
load_balancer_arn = aws_lb.this.arn
protocol = "HTTP"
port = var.ingress_port
default_action {
target_group_arn = var.target_group.arn
type = "forward"
}
}