簡體   English   中英

AWS Load Balancer Terraform 模塊(https://github.com/terraform-aws-modules/terraform-aws-alb):target_group_index = 0,是什么?

[英]AWS Load Balancer Terraform module (https://github.com/terraform-aws-modules/terraform-aws-alb): target_group_index = 0, what is it?

我嘗試使用模塊 AWS 應用程序和網絡負載均衡器(ALB 和 NLB)Terraform 模塊https://github.com/terraform-aws-modules/terraform-aws-alb 有一個 Application Load Balancer 的示例用法,見下文:

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?

在您發布的示例中,只有一個目標組(TG):

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

因此,偵聽器使用target_group_index = 0來指示它們適用於這個特定的 TG。 如果您有更多的 TG,您將使用target_group_index = 1, 2, 3 ...來指定適用於每個 TG 的偵聽器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM