Can I get confirmation of the menaing of the "Warning: Interpolation-only expressions are deprecated"

Hi all,

I have read some posts about this but I would like another opinion. We have some old v0.11 scripts that are not upgraded. Example section is:

resource "azurerm_kubernetes_cluster" "k8s" {
  name                = var.aks_name
  location            = "${data.azurerm_resource_group.main.location}"
  dns_prefix          = "${var.k8s_dns_prefix}-${data.azurerm_resource_group.main.name}"
  resource_group_name = "${data.azurerm_resource_group.main.name}"
  node_resource_group = "Nodes_${data.azurerm_resource_group.main.name}"
  kubernetes_version  = var.kubernetes_version

.
.
.

Am I right in thinking that for those parameters that refer to a single variable, I should remove the "${....}", and for those that use additional text or combined variables, I should leave them alone?

As an example of the above as an updated version, would this be correct:

resource "azurerm_kubernetes_cluster" "k8s" {
  name                = var.aks_name
  location            = data.azurerm_resource_group.main.location
  dns_prefix          = "${var.k8s_dns_prefix}-${data.azurerm_resource_group.main.name}"
  resource_group_name = data.azurerm_resource_group.main.name
  node_resource_group = "Nodes_${data.azurerm_resource_group.main.name}"
  kubernetes_version  = var.kubernetes_version
.  
.
.

Yes, you have understood correctly.

1 Like

Indeed, and if you’d prefer to eliminate all of these warnings in a single step you could potentially try installing the latest patch release of Terraform v0.12 and then using its automatic upgrade command to replace the deprecated syntax:

terraform 0.12upgrade

This command is only available in the Terraform v0.12 series, but if you’re using a later version of Terraform there should be no harm in using v0.12 just to run that command above. That command will only change your local configuration on disk, so you will get a chance to review what it did and decide whether you’d like to keep the result.

If you want to do this you’ll need to do it before you manually make any changes to use the new syntax, because the upgrade tool uses Terraform v0.11’s configuration parser and will fail if given new-style syntax as its input.

1 Like