Closed adamwshero closed 1 year ago
I faced the same problem. My workaround is, assuming nlb
and alb
are both using terraform-aws-modules/alb/aws
with version = "~> 8.0"
module "nlb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 8.0"
load_balancer_type = "network"
# other properties
target_groups = [
{
name_prefix = "pref-"
backend_protocol = "TCP"
backend_port = 80
target_type = "alb"
# target_id = module.alb[0].lb_arn # TODO does not work yet.
}
]
http_tcp_listeners = [
{
port = 80
protocol = "TCP"
target_group_index = 0
}
]
}
## WORKAROUND
resource "aws_lb_target_group_attachment" "nlb_to_alb" {
target_group_arn = module.nlb.target_group_arns[0]
target_id = module.alb.lb_arn
port = 80
}
This might be worth submitting as a PR. I'm using Terragrunt so I can't make a workaround like this possible without forking this repository and referencing it as a source instead.
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
Please keep this alive as it is a real issue that needs to be addressed.
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
keep alive
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
keep alive
@mavogel I am attaching an NLB to an existing ALB using:
targets = {
alb_target = {
target_id = module.alb.lb_arn
port = 443
}
}
In your example it would be:
module "nlb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 8.0"
load_balancer_type = "network"
# other properties
target_groups = [
{
name_prefix = "pref-"
backend_protocol = "TCP"
backend_port = 80
target_type = "alb"
targets = {
alb_target = {
target_id = module.alb.lb_arn
port = 80
}
}
}
]
http_tcp_listeners = [
{
port = 80
protocol = "TCP"
target_group_index = 0
}
]
}
That actually worked for me now and I also upgraded to the v8.6.0 release nischal-flywire. Thank you for posting this. FYI the full Terragrunt input block looks like this. Hopefully the owners of this module can add this in the examples.
inputs = {
name = "${local.prefix}-${local.product}-${local.env}"
load_balancer_type = "network"
internal = true
idle_timeout = 350
vpc_id = dependency.vpc.outputs.vpc_id
subnets = dependency.vpc.outputs.private_subnets
access_logs = {
enabled = true
bucket = dependency.nlb_logs.outputs.s3_bucket_id
prefix = "${local.prefix}-${local.product}-${local.env}"
}
http_tcp_listeners = [
{
port = 443
protocol = "TCP"
action_type = "forward"
target_group_index = 0
}
]
target_groups = [
{
name = "${local.prefix}-my-service-name-${local.env}"
backend_port = 9098
backend_protocol = "TCP"
target_type = "alb"
health_check = {
enabled = true
protocol = "HTTPS"
path = "/health"
port = 9098
healthy_threshold = 3
unhealthy_threshold = 3
interval = 30
}
targets = {
alb_target = {
target_id = dependency.alb.outputs.lb_arn
port = 9098
}
}
}
]
tags = local.tags
}
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Is your request related to a new offering from AWS?
Is this functionality available in the AWS provider for Terraform? See CHANGELOG.md, too.
aws 4.0.0
Is your request related to a problem? Please describe.
Using any module tag version (e.g. v7.0.0), and when creating a network load balancer with the
target_type
as "alb", you are unable to attach to an existing ALB & Target group. Instead, a target group is created for you using thename
attribute and any target group attachments seem to be ignored.Describe the solution you'd like.
I would expect to be able to either specify the loadBalancerArns
list(string)
and targetGroupArnstring
in thetarget_groups
block.Describe alternatives you've considered.
Could possibly specify the loadBalancerArns
list(string)
and targetGroupArnstring
as part of thetarget_group_attachments
block.Additional context
Possible example of desired solution: