While adding listener rules to ALB using Terraform “aws_alb_listener_rule” getting this error
`reading ELBv2 Target Group (arn:aws:elasticloadbalancing:us-east-1:XXX:targetgroup/my-tg/XXX): ValidationError: 'arn:aws:elasticloadbalancing:us-east-1:xxx:targetgroup/my-tg/xxx' is not a valid target group ARN`
`│ status code: 400, request id: xxx`
I m adding multiple rules as I want to forward them to multiple target groups
resource "aws_alb_listener_rule" "forward_to_respective_tg" {
for_each = local.target_group_config
listener_arn = aws_alb_listener._my_listener.arn
priority = each.value.listener_rules.priority
action {
type = "forward"
target_group_arn = aws_lb_target_group.my_tg[each.key].arn
}
condition {
path_pattern {
values = [each.value.listener_rules.path_pattern]
}
}
}