0

我正在尝试在 http_listener_rule 资源中使用 ALB 模块值。我发现只有一种方法是使用以下语法:资源中的“${module.alb.http_tcp_listener_arns}”但这会引发以下错误:属性“listener_arn”的值不合适:需要字符串。

出现以下错误:错误:main.tf 第 197 行的属性值类型不正确,在资源“aws_lb_listener_rule”“host_based_routing”中:197:listener_arn = “${module.alb.http_tcp_listener_arns}”├──────── ──────── │ module.alb.http_tcp_listener_arns 是空元组

属性“listener_arn”的值不合适:需要字符串。

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 = "git@github.com: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"
      }
    }
  ]
}
4

1 回答 1

0

module.alb.http_tcp_listener_arnsARN 列表,因此您必须为您的host_based_routing. 如果你只有一个,那么你可以尝试:

listener_arn = module.alb.http_tcp_listener_arns[0]
于 2021-06-30T08:10:54.207 回答