From f6a6956c8bd4135123584cbb5e1e151f2b8840c4 Mon Sep 17 00:00:00 2001 From: Deepak verma <89906661+deepakvermacloud@users.noreply.github.com> Date: Wed, 10 Aug 2022 22:10:11 +0530 Subject: [PATCH] Revert "Yaac" --- _example/alb/example.tf | 3 +-- _example/clb/example.tf | 3 +-- _example/nlb/example.tf | 1 - main.tf | 14 +++++++------- variables.tf | 7 ------- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/_example/alb/example.tf b/_example/alb/example.tf index 6f0ed99..29577a2 100644 --- a/_example/alb/example.tf +++ b/_example/alb/example.tf @@ -119,7 +119,7 @@ module "ec2" { instance_profile_enabled = true iam_instance_profile = module.iam-role.name - + ebs_optimized = false ebs_volume_enabled = true ebs_volume_type = "gp2" @@ -138,7 +138,6 @@ module "alb" { security_groups = [module.ssh.security_group_ids, module.http_https.security_group_ids] subnets = module.public_subnets.public_subnet_id enable_deletion_protection = false - with_target_group = true target_id = module.ec2.instance_id vpc_id = module.vpc.vpc_id diff --git a/_example/clb/example.tf b/_example/clb/example.tf index 285b33d..29a52a5 100644 --- a/_example/clb/example.tf +++ b/_example/clb/example.tf @@ -117,7 +117,7 @@ module "ec2" { instance_profile_enabled = true iam_instance_profile = module.iam-role.name - + ebs_optimized = false ebs_volume_enabled = true ebs_volume_type = "gp2" @@ -134,7 +134,6 @@ module "clb" { target_id = module.ec2.instance_id security_groups = [module.ssh.security_group_ids, module.http_https.security_group_ids] subnets = module.public_subnets.public_subnet_id - with_target_group = true listeners = [ { diff --git a/_example/nlb/example.tf b/_example/nlb/example.tf index 71aed76..f5846d8 100644 --- a/_example/nlb/example.tf +++ b/_example/nlb/example.tf @@ -135,7 +135,6 @@ module "nlb" { instance_count = module.ec2.instance_count subnets = module.public_subnets.public_subnet_id enable_deletion_protection = false - with_target_group = true target_id = module.ec2.instance_id vpc_id = module.vpc.vpc_id diff --git a/main.tf b/main.tf index ddc7d11..6d5dccc 100644 --- a/main.tf +++ b/main.tf @@ -60,7 +60,7 @@ resource "aws_lb" "main" { # Module : LOAD BALANCER LISTENER HTTPS # Description : Provides a Load Balancer Listener resource. resource "aws_lb_listener" "https" { - count = var.enable == true && var.with_target_group && var.https_enabled == true && var.load_balancer_type == "application" ? 1 : 0 + count = var.enable == true && var.https_enabled == true && var.load_balancer_type == "application" ? 1 : 0 load_balancer_arn = element(aws_lb.main.*.arn, count.index) port = var.https_port @@ -85,7 +85,7 @@ resource "aws_lb_listener" "https" { # Module : LOAD BALANCER LISTENER HTTP # Description : Provides a Load Balancer Listener resource. resource "aws_lb_listener" "http" { - count = var.enable == true && var.with_target_group && var.http_enabled == true && var.load_balancer_type == "application" ? 1 : 0 + count = var.enable == true && var.http_enabled == true && var.load_balancer_type == "application" ? 1 : 0 load_balancer_arn = element(aws_lb.main.*.arn, count.index) port = var.http_port @@ -104,7 +104,7 @@ resource "aws_lb_listener" "http" { # Module : LOAD BALANCER LISTENER HTTPS # Description : Provides a Load Balancer Listener resource. resource "aws_lb_listener" "nhttps" { - count = var.enable == true && var.with_target_group && var.https_enabled == true && var.load_balancer_type == "network" ? length(var.https_listeners) : 0 + count = var.enable == true && var.https_enabled == true && var.load_balancer_type == "network" ? length(var.https_listeners) : 0 load_balancer_arn = element(aws_lb.main.*.arn, count.index) port = var.https_listeners[count.index]["port"] @@ -120,7 +120,7 @@ resource "aws_lb_listener" "nhttps" { # Module : LOAD BALANCER LISTENER HTTP # Description : Provides a Load Balancer Listener resource. resource "aws_lb_listener" "nhttp" { - count = var.enable == true && var.with_target_group && var.load_balancer_type == "network" ? length(var.http_tcp_listeners) : 0 + count = var.enable == true && var.load_balancer_type == "network" ? length(var.http_tcp_listeners) : 0 load_balancer_arn = element(aws_lb.main.*.arn, 0) port = var.http_tcp_listeners[count.index]["port"] @@ -134,7 +134,7 @@ resource "aws_lb_listener" "nhttp" { # Module : LOAD BALANCER TARGET GROUP # Description : Provides a Target Group resource for use with Load Balancer resources. resource "aws_lb_target_group" "main" { - count = var.enable && var.with_target_group ? length(var.target_groups) : 0 + count = var.enable ? length(var.target_groups) : 0 name = format("%s-%s", module.labels.id, count.index) port = lookup(var.target_groups[count.index], "backend_port", null) protocol = lookup(var.target_groups[count.index], "backend_protocol", null) != null ? upper(lookup(var.target_groups[count.index], "backend_protocol")) : null @@ -177,7 +177,7 @@ resource "aws_lb_target_group" "main" { # Description : Provides the ability to register instances and containers with an # Application Load Balancer (ALB) or Network Load Balancer (NLB) target group. resource "aws_lb_target_group_attachment" "attachment" { - count = var.enable && var.with_target_group && var.load_balancer_type == "application" && var.target_type == "" ? var.instance_count : 0 + count = var.enable && var.load_balancer_type == "application" && var.target_type == "" ? var.instance_count : 0 target_group_arn = element(aws_lb_target_group.main.*.arn, count.index) target_id = element(var.target_id, count.index) @@ -185,7 +185,7 @@ resource "aws_lb_target_group_attachment" "attachment" { } resource "aws_lb_target_group_attachment" "nattachment" { - count = var.enable && var.with_target_group && var.load_balancer_type == "network" ? length(var.https_listeners) : 0 + count = var.enable && var.load_balancer_type == "network" ? length(var.https_listeners) : 0 target_group_arn = element(aws_lb_target_group.main.*.arn, count.index) target_id = element(var.target_id, 0) diff --git a/variables.tf b/variables.tf index def4bea..7920901 100644 --- a/variables.tf +++ b/variables.tf @@ -371,10 +371,3 @@ variable "https_listener_rules" { default = [] } -variable "with_target_group" { - type = bool - default = true - description = "Create LoadBlancer without target group" -} - -