-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy path7.alb.tf.txt
47 lines (40 loc) · 1.11 KB
/
7.alb.tf.txt
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
[root@ip-172-31-39-240 vasu]# cat alb.tf
resource "aws_lb_target_group" "myapp_tg" {
name = "myapp-tg"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.main.id
health_check {
protocol = "HTTP"
path = "/index.html"
port = 80
}
}
# add targets to target group
resource "aws_lb_target_group_attachment" "test" {
target_group_arn = aws_lb_target_group.myapp_tg.arn
target_id = aws_instance.web.id
port = 80
}
# Application load balancer
resource "aws_lb" "myapp_alb" {
name = "myapp-alb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.web_sg.id]
subnets = aws_subnet.public.*.id
tags = {
Environment = terraform.workspace
}
}
# add listner to ALB
resource "aws_lb_listener" "webapp" {
load_balancer_arn = aws_lb.myapp_alb.arn
port = "80"
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.myapp_tg.arn
}
}
[root@ip-172-31-39-240 vasu]#