Score:0

Terraform - can’t extract ipv4 value with errors

gb flag

any idea how to extract from the code below fixed_ip_v4 for network named test? I'd like to extract that value for ansible inventory.

resource "openstack_compute_instance_v2" "test_terraform_instance" {
  name        = "tmpnode${count.index}"
  count       = var.node_count
  provider    = openstack.ovh
  image_name  = "Debian 10"
  flavor_name = var.flavor_name  #"s1-2"
  key_pair    = openstack_compute_keypair_v2.test_keypair.name
  network {
    name      = "Ext-Net"
  }
  network {
    name = "test"
    fixed_ip_v4 = element(var.front_private_ip, count.index)
  }
}

What I already tried and the errors:

  • openstack_compute_instance_v2.test_terraform_instance[*].network.name[test].fixed_ip_v4 ?

    Can't access attributes on a list of objects. Did you mean to access attribute "name" for a specific element of the list, or across all elements of the list?

  • openstack_compute_instance_v2.test_terraform_instance[*].network[*].fixed_ip_v4.network[“test”].fixed_ip_v4

    error Doesn't work without double and with single quotes in network[“test”] neither.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.