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。有应用负载均衡器的使用示例,见下:
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。
我尝试使用模块,AWS 应用程序和网络负载均衡器(ALB 和 NLB)Terraform 模块,https://github.com/terraform-aws-modules/terraform-aws-alb。有应用负载均衡器的使用示例,见下:
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。