首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AWS负载均衡器Terraform模块(https://github.com/terraform-aws-modules/terraform-aws-alb):target_group_index = 0,是什么?

AWS负载均衡器Terraform模块(https://github.com/terraform-aws-modules/terraform-aws-alb):target_group_index = 0,是什么?
EN

Stack Overflow用户
提问于 2020-11-23 00:39:29
回答 1查看 1.3K关注 0票数 0

我尝试使用的模块,AWS应用和网络负载均衡器(ALB &北草坪会议大楼)平台模块,https://github.com/terraform-aws-modules/terraform-aws-alb。下面是应用程序负载均衡器的示例用法:

代码语言:javascript
复制
module "alb" {
  source  = "terraform-aws-modules/alb/aws"
  version = "~> 5.0"
  
  name = "my-alb"

  load_balancer_type = "application"

  vpc_id             = "vpc-abcde012"
  subnets            = ["subnet-abcde012", "subnet-bcde012a"]
  security_groups    = ["sg-edcd9784", "sg-edcd9785"]
  
  access_logs = {
    bucket = "my-alb-logs"
  }

  target_groups = [
    {
      name_prefix      = "pref-"
      backend_protocol = "HTTP"
      backend_port     = 80
      target_type      = "instance"
    }
  ]

  https_listeners = [
    {
      port               = 443
      protocol           = "HTTPS"
      certificate_arn    = "arn:aws:iam::123456789012:server-certificate/test_cert-123456789012"
      target_group_index = 0
    }
  ]

  http_tcp_listeners = [
    {
      port               = 80
      protocol           = "HTTP"
      target_group_index = 0
    }
  ]

  tags = {
    Environment = "Test"
  }
}

我知道target_groups是一个数组。但是,为什么target_group_index =0而不是target_group_index =1或target_group_index = 2呢?指数0是多少?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-23 00:47:53

在您发布的示例中,只有一个目标组 (TG):

代码语言:javascript
复制
  target_groups = [
    {
      name_prefix      = "pref-"
      backend_protocol = "HTTP"
      backend_port     = 80
      target_type      = "instance"
    }
  ]

因此,侦听器使用target_group_index = 0来指示它们应用于这个特定的TG。如果您有更多的TGs,您将使用target_group_index = 1, 2, 3 ...来指定哪个侦听器应用于每个TG。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64961193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档