-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalb.tf
More file actions
47 lines (44 loc) · 1018 Bytes
/
Copy pathalb.tf
File metadata and controls
47 lines (44 loc) · 1018 Bytes
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
resource "aws_security_group" "nginx_sg" {
vpc_id = aws_vpc.main.id
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "nginx_sg"
}
}
resource "aws_lb" "nginx_lb" {
name = "nginx-lb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.nginx_sg.id]
subnets = [
aws_subnet.public.id,
aws_subnet.sub.id
]
}
resource "aws_lb_target_group" "nginx_tg" {
name = "nginx-tg"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.main.id
target_type = "ip"
}
resource "aws_lb_listener" "nginx_listener" {
load_balancer_arn = aws_lb.nginx_lb.arn
port = "80"
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.nginx_tg.arn
}
}