【发布时间】:2021-12-17 16:04:17
【问题描述】:
我正在使用 terraform 将实例分配给 lb_target_group。
我有 3 个服务器,分别命名为: test-1 、 test-2 、 test-3 - 这些服务器是从一个模块创建的,我做了一个输出
下面是使用单个实例的代码:test-1
我的目标是包含所有 3 台服务器
** 服务器输出 **
output "test-1-id" {
value = module.test-1.tps-vm-instance-id
}
output "test-2-id" {
value = module.test-2.tps-vm-instance-id
}
output "test-3-id" {
value = module.test-3.tps-vm-instance-id
}
工作代码
resource "aws_lb_target_group" "test_node_instances_group" {
name = "test-node-instances-group"
port = 443
protocol = "HTTPS"
vpc_id = module.vpc.vpc-id
}
resource "aws_lb_target_group_attachment" "test_node_instances" {
target_group_arn = aws_lb_target_group.test_node_instances_group.arn
target_id = module.test.test-1-id
port = 443
不适合我的代码
resource "aws_lb_target_group" "test_node_instances_group" {
name = "test-node-instances-group"
port = 443
protocol = "HTTPS"
vpc_id = module.vpc.vpc-id
}
resource "aws_lb_target_group_attachment" "test_node_instances" {
count = 2
target_group_arn = aws_lb_target_group.test_node_instances_group.arn
target_id = module.test.test-[count.index]-id
port = 443
感谢您的建议
【问题讨论】:
-
aws_instance.test-1-id的定义是什么?
标签: terraform terraform-provider-aws