-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
58 lines (49 loc) · 1.47 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
data "aws_lb" "selected" {
arn = var.alb_arn
}
# Enable private link for shoplytics-api-preivew
resource "aws_lb" "this" {
name = "nlb-${var.service_name}"
internal = true
load_balancer_type = "network"
subnets = [for subnet in data.aws_lb.selected.subnet_mapping : subnet.subnet_id]
tags = var.nlb_tags
}
resource "aws_lb_target_group" "this" {
name = "tg-alb-${var.service_name}"
target_type = "alb"
port = 80
protocol = "TCP"
vpc_id = data.aws_lb.selected.vpc_id
health_check {
interval = 30
protocol = "HTTP"
path = "/health_check"
healthy_threshold = 3
unhealthy_threshold = 3
timeout = 10
}
}
resource "aws_lb_target_group_attachment" "this" {
target_group_arn = aws_lb_target_group.this.arn
target_id = var.alb_arn
port = 80
}
resource "aws_lb_listener" "this" {
load_balancer_arn = aws_lb.this.arn
port = "80"
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.this.arn
}
}
resource "aws_vpc_endpoint_service" "this" {
acceptance_required = false
network_load_balancer_arns = [aws_lb.this.arn]
tags = var.endpoint_service_tags
}
resource "aws_vpc_endpoint_service_allowed_principal" "this" {
vpc_endpoint_service_id = aws_vpc_endpoint_service.this.id
principal_arn = var.principal_arn
}