@@ -60,7 +60,7 @@ resource "aws_lb" "main" {
60
60
# Module : LOAD BALANCER LISTENER HTTPS
61
61
# Description : Provides a Load Balancer Listener resource.
62
62
resource "aws_lb_listener" "https" {
63
- count = var. enable == true && var. https_enabled == true && var. load_balancer_type == " application" ? 1 : 0
63
+ count = var. enable == true && var. with_target_group && var . https_enabled == true && var. load_balancer_type == " application" ? 1 : 0
64
64
65
65
load_balancer_arn = element (aws_lb. main . * . arn , count. index )
66
66
port = var. https_port
@@ -85,7 +85,7 @@ resource "aws_lb_listener" "https" {
85
85
# Module : LOAD BALANCER LISTENER HTTP
86
86
# Description : Provides a Load Balancer Listener resource.
87
87
resource "aws_lb_listener" "http" {
88
- count = var. enable == true && var. http_enabled == true && var. load_balancer_type == " application" ? 1 : 0
88
+ count = var. enable == true && var. with_target_group && var . http_enabled == true && var. load_balancer_type == " application" ? 1 : 0
89
89
90
90
load_balancer_arn = element (aws_lb. main . * . arn , count. index )
91
91
port = var. http_port
@@ -104,7 +104,7 @@ resource "aws_lb_listener" "http" {
104
104
# Module : LOAD BALANCER LISTENER HTTPS
105
105
# Description : Provides a Load Balancer Listener resource.
106
106
resource "aws_lb_listener" "nhttps" {
107
- count = var. enable == true && var. https_enabled == true && var. load_balancer_type == " network" ? length (var. https_listeners ) : 0
107
+ count = var. enable == true && var. with_target_group && var . https_enabled == true && var. load_balancer_type == " network" ? length (var. https_listeners ) : 0
108
108
109
109
load_balancer_arn = element (aws_lb. main . * . arn , count. index )
110
110
port = var. https_listeners [count . index ][" port" ]
@@ -120,7 +120,7 @@ resource "aws_lb_listener" "nhttps" {
120
120
# Module : LOAD BALANCER LISTENER HTTP
121
121
# Description : Provides a Load Balancer Listener resource.
122
122
resource "aws_lb_listener" "nhttp" {
123
- count = var. enable == true && var. load_balancer_type == " network" ? length (var. http_tcp_listeners ) : 0
123
+ count = var. enable == true && var. with_target_group && var . load_balancer_type == " network" ? length (var. http_tcp_listeners ) : 0
124
124
125
125
load_balancer_arn = element (aws_lb. main . * . arn , 0 )
126
126
port = var. http_tcp_listeners [count . index ][" port" ]
@@ -134,7 +134,7 @@ resource "aws_lb_listener" "nhttp" {
134
134
# Module : LOAD BALANCER TARGET GROUP
135
135
# Description : Provides a Target Group resource for use with Load Balancer resources.
136
136
resource "aws_lb_target_group" "main" {
137
- count = var. enable ? length (var. target_groups ) : 0
137
+ count = var. enable && var . with_target_group ? length (var. target_groups ) : 0
138
138
name = format (" %s-%s" , module. labels . id , count. index )
139
139
port = lookup (var. target_groups [count . index ], " backend_port" , null )
140
140
protocol = lookup (var. target_groups [count . index ], " backend_protocol" , null ) != null ? upper (lookup (var. target_groups [count . index ], " backend_protocol" )) : null
@@ -177,15 +177,15 @@ resource "aws_lb_target_group" "main" {
177
177
# Description : Provides the ability to register instances and containers with an
178
178
# Application Load Balancer (ALB) or Network Load Balancer (NLB) target group.
179
179
resource "aws_lb_target_group_attachment" "attachment" {
180
- count = var. enable && var. load_balancer_type == " application" && var. target_type == " " ? var. instance_count : 0
180
+ count = var. enable && var. with_target_group && var . load_balancer_type == " application" && var. target_type == " " ? var. instance_count : 0
181
181
182
182
target_group_arn = element (aws_lb_target_group. main . * . arn , count. index )
183
183
target_id = element (var. target_id , count. index )
184
184
port = var. target_group_port
185
185
}
186
186
187
187
resource "aws_lb_target_group_attachment" "nattachment" {
188
- count = var. enable && var. load_balancer_type == " network" ? length (var. https_listeners ) : 0
188
+ count = var. enable && var. with_target_group && var . load_balancer_type == " network" ? length (var. https_listeners ) : 0
189
189
190
190
target_group_arn = element (aws_lb_target_group. main . * . arn , count. index )
191
191
target_id = element (var. target_id , 0 )
0 commit comments