From 482f84462b49de705436ea5335afbf5b59be2edb Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 22 Oct 2023 20:41:34 +0100 Subject: [PATCH] magical fixes --- aws_modules/load_balancer/main.tf | 76 +++++++++++++-------------- aws_modules/load_balancer/output.tf | 2 +- aws_modules/load_balancer/variable.tf | 4 ++ 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/aws_modules/load_balancer/main.tf b/aws_modules/load_balancer/main.tf index ca61660..66fae34 100644 --- a/aws_modules/load_balancer/main.tf +++ b/aws_modules/load_balancer/main.tf @@ -1,52 +1,52 @@ resource "aws_lb" "alb" { + name = var.alb_name + internal = true + load_balancer_type = "application" +# security_groups = aws_security_group.security_group.id + subnets = ["value"] + enable_http2 = false + enable_deletion_protection = false + + tags = { name = "${var.alb_name}" - internal = true - load_balancer_type = "applcation" - security_groups = aws_security_group.security_group.id - subnets = [ "value" ] - enable_http2 = false - enable_deletion_protection = false - - tags = { - name = "${var.alb_name}" - } + } } resource "aws_lb_target_group" "target_group" { - name = "${var.tg_name}" - port = 80 - protocol = "HTTP" - target_type = "instance" - vpc_id = [] - - health_check { - path = "/" - protocol = "HTTP" - matcher = "200" - interval = 15 - healthy_threshold = 3 - timeout = 3 - unhealthy_threshold = 3 - } - + name = var.alb_tg_name + port = 80 + protocol = "HTTP" + target_type = "instance" +# vpc_id = [] + + health_check { + path = "/" + protocol = "HTTP" + matcher = "200" + interval = 15 + healthy_threshold = 3 + timeout = 3 + unhealthy_threshold = 3 + } + } resource "aws_lb_target_group_attachment" "tg_atch" { - target_group_arn = aws_lb_target_group.target_group.arn - target_id = aws_lb_target_group.target_group.id - port = 80 + target_group_arn = aws_lb_target_group.target_group.arn + target_id = aws_lb_target_group.target_group.id + port = 80 } resource "aws_lb_listener" "front_end" { - load_balancer_arn = aws_lb.alb.arn - port = "80" - protocol = "HTTP" - - default_action { - type = "forward" - target_group_arn = aws_lb_target_group.target_group.arn - } - + load_balancer_arn = aws_lb.alb.arn + port = "80" + protocol = "HTTP" + + default_action { + type = "forward" + target_group_arn = aws_lb_target_group.target_group.arn + } + } diff --git a/aws_modules/load_balancer/output.tf b/aws_modules/load_balancer/output.tf index 0f8b7ce..b2f24b9 100644 --- a/aws_modules/load_balancer/output.tf +++ b/aws_modules/load_balancer/output.tf @@ -1,3 +1,3 @@ output "alb_id" { - value = aws_lb.lb.dns_name + value = aws_lb.alb } \ No newline at end of file diff --git a/aws_modules/load_balancer/variable.tf b/aws_modules/load_balancer/variable.tf index 98c79a1..c871300 100644 --- a/aws_modules/load_balancer/variable.tf +++ b/aws_modules/load_balancer/variable.tf @@ -3,3 +3,7 @@ variable "alb_name" { type = string } +variable "alb_tg_name" { + description ="name of the application load balancer target group" + type = string +}