title: spin multiple instances of different images using terraform on openstack
body: <p>I've been trying to spin up multiple instances of different images using terraform but haven't had luck so far. I could spin multiple instances of a single image with <code>count</code>. While spinning up different images with <code>for_each</code>, I couldn't get the right configuration. </p>
  
  <p>I've the below variable .tf configuration file.</p>
  
  <pre><code>variable "images" {
    type = map
    default = {
      "rhel-8-factory-os-ready" = {
         "az_zone" = "eu-fra-1ah"
         "ins_count" = 2
       }
      "rhel-7-factory-os-ready" = {
         "az_zone" = "eu-fra-1ai"
         "ins_count" = 2
      }
    }
  }
  
  resource "openstack_compute_instance_v2" "instance" {
     for_each = var.images
     flavor_id = var.flavor
     image_name = each.key
     name = "${var.image_name}-${lower(random_id.random-instance.hex)}"
     availability_zone = each.value.az_zone
     security_groups = var.security_group
     key_pair = "fop-mgt-key"
     network {
       name = var.network_name
     }
  }
  
  resource "random_id" "random-instance" {
    byte_length = 4
  }
  
  resource "random_id" "random-number" {
    byte_length = 8
  }
  
  resource "openstack_networking_floatingip_v2" "fip" {
    count = length(var.images)
    pool = var.floatingip_pool
  }
  
  resource "openstack_compute_floatingip_associate_v2" "fip" {
  
    depends_on = [openstack_compute_instance_v2.instance]
  
    count = length(var.images)
    floating_ip = openstack_networking_floatingip_v2.fip[count.index].address
    instance_id = openstack_compute_instance_v2.instance.*.id[count.index]
    fixed_ip    = openstack_compute_instance_v2.instance.*.network.0.fixed_ip_v4[count.index]
  }
  
  terraform {
    backend "artifactory" {}
  }
  
  data "terraform_remote_state" "foo" {
    backend = "artifactory"
    config = {
      repo = "${var.repo}"
      subpath = "${var.subpath}"
    }
  }
  </code></pre>
  
  <p>I see the below error message ::</p>
  
  <blockquote>
    <p>Error: Unsupported attribute</p>
    
    <p>on tf-backend-fra/main.tf line 49, in resource
    "openstack_compute_floatingip_associate_v2" "fip":   49:   instance_id
    = openstack_compute_instance_v2.instance.*.id[count.index]</p>
    
    <p>This object does not have an attribute named "id".</p>
  </blockquote>
  
  <p>I'm not sure how to get it done with <code>for_each</code>. Terraform version is 0.12.17.
  Your help is much appreciated.</p>
  
  <p>Thanks,
  Harsha</p>