Skip to content

Adds key to TG name #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ resource "aws_lb_target_group" "lb_http_tgs" {
for name, config in var.http_ports : name => config
if lookup(config, "type", "") == "" || lookup(config, "type", "") == "forward"
}
name = "${var.name_prefix}-http-${each.value.target_group_port}"
name = "${var.name_prefix}-${each.key}-http-${each.value.target_group_port}"
port = each.value.target_group_port
protocol = lookup(each.value, "target_group_protocol", "") == "" ? "HTTP" : each.value.target_group_protocol
protocol = lookup(each.value, "target_group_protocol", "HTTP")
vpc_id = var.vpc_id
deregistration_delay = var.deregistration_delay
slow_start = var.slow_start
Expand All @@ -139,7 +139,7 @@ resource "aws_lb_target_group" "lb_http_tgs" {
enabled = var.target_group_health_check_enabled
interval = var.target_group_health_check_interval
path = var.target_group_health_check_path
protocol = lookup(each.value, "target_group_protocol", "") == "" ? "HTTP" : each.value.target_group_protocol
protocol = lookup(each.value, "target_group_protocol", "HTTP")
timeout = var.target_group_health_check_timeout
healthy_threshold = var.target_group_health_check_healthy_threshold
unhealthy_threshold = var.target_group_health_check_unhealthy_threshold
Expand All @@ -149,7 +149,7 @@ resource "aws_lb_target_group" "lb_http_tgs" {
tags = merge(
var.tags,
{
Name = "${var.name_prefix}-http-${each.value.target_group_port}"
Name = "${var.name_prefix}-${each.key}-http-${each.value.target_group_port}"
},
)
lifecycle {
Expand All @@ -163,9 +163,9 @@ resource "aws_lb_target_group" "lb_https_tgs" {
for name, config in var.https_ports : name => config
if lookup(config, "type", "") == "" || lookup(config, "type", "") == "forward"
}
name = "${var.name_prefix}-https-${each.value.target_group_port}"
name = "${var.name_prefix}-${each.key}-https-${each.value.target_group_port}"
port = each.value.target_group_port
protocol = lookup(each.value, "target_group_protocol", "") == "" ? "HTTPS" : each.value.target_group_protocol
protocol = lookup(each.value, "target_group_protocol", "HTTPS")
vpc_id = var.vpc_id
deregistration_delay = var.deregistration_delay
slow_start = var.slow_start
Expand All @@ -182,7 +182,7 @@ resource "aws_lb_target_group" "lb_https_tgs" {
enabled = var.target_group_health_check_enabled
interval = var.target_group_health_check_interval
path = var.target_group_health_check_path
protocol = lookup(each.value, "target_group_protocol", "") == "" ? "HTTPS" : each.value.target_group_protocol
protocol = lookup(each.value, "target_group_protocol", "HTTPS")
timeout = var.target_group_health_check_timeout
healthy_threshold = var.target_group_health_check_healthy_threshold
unhealthy_threshold = var.target_group_health_check_unhealthy_threshold
Expand All @@ -192,7 +192,7 @@ resource "aws_lb_target_group" "lb_https_tgs" {
tags = merge(
var.tags,
{
Name = "${var.name_prefix}-https-${each.value.target_group_port}"
Name = "${var.name_prefix}-${each.key}-https-${each.value.target_group_port}"
},
)
lifecycle {
Expand Down
10 changes: 5 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ variable "http_ports" {
description = "Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener_port and the target_group_port. For `redirect` type, include listener port, host, path, port, protocol, query and status_code. For `fixed-response`, include listener_port, content_type, message_body and status_code"
type = map(any)
default = {
default_http = {
default = {
type = "forward"
listener_port = 80
target_group_port = 80
Expand All @@ -155,7 +155,7 @@ variable "https_ports" {
description = "Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener_port and the target_group_port. For `redirect` type, include listener port, host, path, port, protocol, query and status_code. For `fixed-response`, include listener_port, content_type, message_body and status_code"
type = map(any)
default = {
default_http = {
default = {
type = "forward"
listener_port = 443
target_group_port = 443
Expand All @@ -170,7 +170,7 @@ Other options for listeners (The same are valid also for https_ports variable):
description = "Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener_port and the target_group_port. For `redirect` type, include listener port, host, path, port, protocol, query and status_code. For `fixed-response`, include listener_port, content_type, message_body and status_code"
type = map(any)
default = {
force_https = {
force-https = {
type = "redirect"
listener_port = 80
host = "#{host}"
Expand All @@ -188,7 +188,7 @@ Fixed response:
description = "Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener_port and the target_group_port. For `redirect` type, include listener port, host, path, port, protocol, query and status_code. For `fixed-response`, include listener_port, content_type, message_body and status_code"
type = map(any)
default = {
fixed_response = {
fixed-response = {
type = "fixed-response"
listener_port = 80
content_type = "text/plain"
Expand All @@ -204,7 +204,7 @@ Additionally, you can have an HTTPS listener forwarding traffic to an HTTP targe
description = "Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener_port and the target_group_port. For `redirect` type, include listener port, host, path, port, protocol, query and status_code. For `fixed-response`, include listener_port, content_type, message_body and status_code"
type = map(any)
default = {
https_listener_to_http_target_group = {
https-to-http-tg = {
type = "forward"
listener_port = 443
target_group_port = 80
Expand Down