Hmm weird error “backend_address_pool.0.ip_addresses.0” is not a valid IPv4 address

2021-06-06T23:00:00Z
Hi
Have spent hours on this. No avail.

I have a module that creates a VM. the module is named VM-Platform-Admin.
inside this module i have an outputs.tf like this,

output “instance_ip” {
value = “azurerm_network_interface.network_interface.private_ip_address”
}

my module is using count. I am able to build a number of VM’s fine. this isnt the problem.

I am now trying to create an app gateway and reference the Ip address inside the NIC of the VM that was created with the VM-Platform-Admin module.
I have left some of the code out for the azurerm_application_gateway. the problem is with the backend_address_pool.

  backend_address_pool {
    name = backend1
    private_ip_addresses = [module.VM-Platform-Admin[0].instance_ip]
  }

The error i get when running an apply is

> Error: “backend_address_pool.0.ip_addresses.0” is not a valid IPv4 address: “azurerm_network_interface.network_interface.private_ip_address”

Anyone had any similar problems with referencing this?

Hi @fdotnhere,

In your example you’ve put the reference expression in quotes, which tells Terraform to take those characters literally as a string value, which indeed isn’t a valid IP address.

I think you intended to write the follow, which will tell Terraform to set the output value to match the value of the object attribute you’re referring to:

output “instance_ip” {
  value = azurerm_network_interface.network_interface.private_ip_address
}

Hi @apparentlymart

Wow thanks. That’s working now. Spent hours on that and totally missed the quotes.
My IDE didn’t raise this but then again why would it…

Big Help. Thanks again