How to evaluate values before applying?

Hello,

I am using Terraform 0.11 and going to update existing infrastructure:

terraform plan
...
~ module.linux.azurerm_dns_cname_record.myrole[0]
    record:  "linux.westeurope.cloudapp.azure.com" => "${element(azurerm_public_ip.myrole.*.fqdn,count.index)}"
...

I don’t want to destroy anything and would like to check what is a value going to be for:

${element(azurerm_public_ip.ubuntu_disk.*.fqdn,count.index)}

Is there any way I can do that before applying ?

Hi @przemolb!

Some values cannot be predicted until the requested object is actually created, because the value is assigned by the remote API and not by the configuration or by Terraform itself. There is no way to look at these values without applying because Terraform itself can’t know them until the create operation has completed.

In this case, it looks like this azurerm_public_ip.ubuntu_disk resource instance is being created in the same plan, so Terraform must wait to see what its fqdn value will be before it can determine this record value.

One way to work more conservatively here is to run terraform apply with the extra option -target=azurerm_public_ip.ubuntu_disk, thus asking Terraform to perform only the actions required to make the azurerm_public_ip.ubuntu_disk instances match the configuration. The -target option is only for exceptional circumstances and not for everyday use for the reasons mentioned in its documentation, but you can use it here as an exceptional process if you are concerned about what value the fqdn attribute will take after apply.

Hi @apparentlymart,
thank you for your response !
I haven’t put it before but at the begin of terraform plan I got this:

Warning: module.ci_agents_linux.azurerm_public_ip.ubuntu_disk[0]: "public_ip_address_allocation": [DEPRECATED] this property has been deprecated in favor of `allocation_method` to better match the api

Is it somehow related to this Warning ? Is there any way I can still use public_ip_address_allocation ?
Or it is not related at all ?