forked from malgus-waf/class5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
9-LoadBalancer.tf
58 lines (48 loc) · 1.42 KB
/
9-LoadBalancer.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
resource "aws_lb" "app1_alb" {
name = "app1-load-balancer"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.app1-sg02-LB01.id]
subnets = [
aws_subnet.public-eu-west-1a.id,
aws_subnet.public-eu-west-1b.id,
aws_subnet.public-eu-west-1c.id
]
enable_deletion_protection = false
#Lots of death and suffering here, make sure it's false
tags = {
Name = "App1LoadBalancer"
Service = "App1"
Owner = "User"
Project = "Web Service"
}
}
resource "aws_lb_listener" "http" {
load_balancer_arn = aws_lb.app1_alb.arn
port = 80
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.app1_tg.arn
}
}
data "aws_acm_certificate" "cert" {
domain = "balerica-aisecops.com"
statuses = ["ISSUED"]
most_recent = true
}
resource "aws_lb_listener" "https" {
load_balancer_arn = aws_lb.app1_alb.arn
port = 443
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2016-08" # or whichever policy suits your requirements
certificate_arn = data.aws_acm_certificate.cert.arn
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.app1_tg.arn
}
}
output "lb_dns_name" {
value = aws_lb.app1_alb.dns_name
description = "The DNS name of the App1 Load Balancer."
}