How to associate floating ip address to a instance in openstack using terraform


i am using terraform to create couple of instances in openstack and i would like to automatically assign floatings ip address to them without any manual intervention.

my .tf file is as below:

resource "openstack_networking_floatingip_v2" "floating-ip" {
 count  = 4
 pool = "floating-ip-pool" 

resource "openstack_compute_floatingip_associate_v2" "fip-associate" {
floating_ip = openstack_networking_floatingip_v2.floating-ip.address[count.0]
instance_id =[count.0]

i am getting an error "Error: Missing resource instance key

on line 33, in resource “openstack_compute_floatingip_associate_v2” “fip-associate”: 33: instance_id =[count.0]"

my terraform version is : Terraform v0.12.24 + provider.openstack 1.26.0