我需要有条件地创建EIP并将其关联到实例:
resource "aws_eip" "gateway" {
vpc = true
tags = {
Name = "${var.project_id}-gateway"
Project = "${var.project_id}"
user = "${var.user}"
}
}
resource "aws_eip_association" "eip_assoc_gateway" {
instance_id = aws_instance.gateway.id
allocation_id = aws_eip.gateway.id
}
resource "aws_instance" "gateway" {
...
}不幸的是,aws_eip和aws_eip_association似乎不支持count属性,所以我不清楚这是否可能?
有什么想法吗?
发布于 2020-03-14 18:04:59
正如注释中提到的,所有Terraform原语资源都支持count。下面是aws_eip的示例:
resource "aws_eip" "eip" {
instance = "${element(aws_instance.manager.*.id,count.index)}"
count = "${var.eip_count}"
vpc = true
}https://stackoverflow.com/questions/60626579
复制相似问题