How to associate multiple Floating ip address to multiple instance in openstack

i am using terraform 0.12 version with the openstack rocky version. I know we are not using “count” in this version so how can we get the 5 instance to get the 5 floating ip addresses. i tried with * as option but it did not work. kindly work

resource “openstack_compute_instance_v2” “terraform_vm” {

name = “automated-vm”
count = 3
image_id = “7e7d212c-8178-48da-bb00-95f0a10df77d”
flavor_id = “3”
key_pair = “openstack vm key”
security_groups = [“default”]

network {
name = “webapps-network”
}
}

resource “openstack_networking_floatingip_v2” “floating_ip” {
count = 3
pool = “floating-ip-pool”
}

resource “openstack_compute_floatingip_associate_v2” “fip_associate” {
floating_ip = openstack_networking_floatingip_v2.floating_ip..address
instance_id = openstack_compute_instance_v2.terraform_vm.
.id
}

able to resolve with for_each option in terraform :slight_smile:
resource “openstack_compute_instance_v2” “terraform_vm” {

image_id = “f8b9189d-2518-4a32-b1ba-2046ea8d47fd”
for_each = var.instance_name
name = each.key
flavor_id = “3”
key_pair = “openstack vm key”
security_groups = [“default”]

network {
name = “webapps-network”
}
}

resource “openstack_networking_floatingip_v2” “floating_ip” {
pool = “floating-ip-pool”
for_each = var.instance_name
}

resource “openstack_compute_floatingip_associate_v2” “fip_associate” {
for_each = var.instance_name
floating_ip = openstack_networking_floatingip_v2.floating_ip[each.key].address
instance_id = openstack_compute_instance_v2.terraform_vm[each.key].id
}