如何有条件地创建awseip和awseip关联



我需要能够有条件地创建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_eipaws_eip_association似乎不支持count属性,所以我不清楚这是否可能?

有什么想法吗?

如注释中所述,所有Terraform原始资源都支持count。下面的aws_eip示例:

resource "aws_eip" "eip" {
instance   = "${element(aws_instance.manager.*.id,count.index)}"
count = "${var.eip_count}"
vpc = true
}

相关内容

  • 没有找到相关文章

最新更新