-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadbalancer.tf
71 lines (61 loc) · 1.73 KB
/
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
59
60
61
62
63
64
65
66
67
68
69
70
71
resource "aws_acm_certificate" "cert" {
domain_name = "aws.zallesov.dev"
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
}
resource "aws_lb" "echo-lb" {
name = "echo-lb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.echo-security-group.id]
subnets = module.vpc.public_subnets
}
resource "aws_security_group" "echo-security-group" {
name = "echo-security-group"
description = "Echo security group"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_lb_target_group" "echo-lb-target-group" {
name = "echo-lb-target-group"
port = 80
protocol = "HTTP"
vpc_id = module.vpc.vpc_id
}
# Target Group for EKS
resource "aws_lb_listener" "echo-lb-listener" {
load_balancer_arn = aws_lb.echo-lb.arn
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = aws_acm_certificate.cert.arn
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.echo-lb-target-group.arn
}
}
# Security group for EKS worker nodes allowing traffic from Load Balancer
resource "aws_security_group" "eks_nodes_sg" {
name = "eks-nodes-sg"
description = "Security group for EKS nodes"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
security_groups = [aws_security_group.echo-security-group.id]
}
}