Using terraform, I need to add 3 elastic IPs to a single new EC2 instance. The terraform yml will be creating the instance as well as the EIPs.
I have tried to do this as follows:
resource "aws_eip" "server_dev1_eip1" {
count = length(aws_instance.server_dev1)
instance = aws_instance.server_dev1.*.id[count.index]
vpc = true
lifecycle {
prevent_destroy = true
}
}
resource "aws_eip" "server_dev1_eip2" {
count = length(aws_instance.server_dev1)
instance = aws_instance.server_dev1.*.id[count.index]
vpc = true
lifecycle {
prevent_destroy = true
}
}
resource "aws_eip" "server_dev1_eip3" {
count = length(aws_instance.server_dev1)
instance = aws_instance.server_dev1.*.id[count.index]
vpc = true
lifecycle {
prevent_destroy = true
}
}
The above is creating the EIPs, but only associating one with the instance.
Please advise