Reputation: 53
I am trying to use ALB module value in http_listener_rule resource. I found only one way to do this that is by using this syntax: “${module.alb.http_tcp_listener_arns}” in resource But this is throwing the following error: Inappropriate value for attribute “listener_arn”: string required.
The following error occurs: Error: Incorrect attribute value type on main.tf line 197, in resource "aws_lb_listener_rule" "host_based_routing": 197: listener_arn = "${module.alb.http_tcp_listener_arns}" ├──────────────── │ module.alb.http_tcp_listener_arns is empty tuple
Inappropriate value for attribute "listener_arn": string required.
resource "aws_lb_listener_rule" "host_based_routing" {
listener_arn = "${module.alb.http_tcp_listener_arns}"
priority = 99
action {
type = "forward"
target_group_arn = "${module.alb.target_group_arns}"
}
condition {
host_header {
values = ["example.com"]
}
}
}
module "alb" {
source = "[email protected]:terraform-aws-modules/terraform-aws-alb.git?ref=v6.0.0"
name = "demo-alb"
load_balancer_type = "application"
vpc_id = module.vpc.vpc_id
subnets = module.vpc.public_subnets
security_groups = [module.security_group_asg.security_group_id]
target_groups = [
{
name = "target-group"
backend_protocol = "HTTP"
backend_port = 80
target_type = "instance"
health_check = {
enabled = true
interval = 110
path = "/drupal"
port = "traffic-port"
healthy_threshold = 3
unhealthy_threshold = 3
timeout = 100
protocol = "HTTP"
matcher = "200-399"
}
}
]
}
Upvotes: 0
Views: 2009
Reputation: 238687
module.alb.http_tcp_listener_arns
is a list of ARNs, so you have to specify individual ARN for your host_based_routing
. If you have only one, then you can try:
listener_arn = module.alb.http_tcp_listener_arns[0]
Upvotes: 0