我正在尝试创建具有 2 个目标组的应用程序负载均衡器。实例位于公共子网中。使用以下代码,我可以创建资源,但实例未附加目标组 a
albmod.tf
no-of-frontend-attachments = "${module.ec2-app-v1.aws-instance}"
变体
variable "no-of-frontend-attachments" {
type = "list"
}
alb.tf
resource "aws_alb_target_group_attachment" "frontend-attachments" {
count = "${length(concat(var.no-of-frontend-attachments))}"
target_group_arn = "${aws_lb_target_group.frontend-target-group.arn}"
target_id = "${element(var.no-of-frontend-attachments,count.index )}"
}
错误
Error: Incorrect attribute value type
on modules/alb/alb.tf line 54, in resource "aws_alb_target_group_attachment" "frontend-attachments":
54: target_id = "${element(var.no-of-frontend-attachments,count.index )}"
|----------------
| count.index is 0
| var.no-of-frontend-attachments is tuple with 1 element
Inappropriate value for attribute "target_id": string required.
我尝试如下更改 target_id 但仍然没有运气。
target_id = "${element(var.no-of-frontend-attachments.*.id, count.index)}"
请帮助我理解这个问题