7
votes

I am trying to use terraform string function and string concatination on a terraform tfvars variable. but when run the terraform plan it through below exception

Error: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.

Following is the terraform code

locals {
  name_suffix = "${var.namespace != "" ? var.namespace : var.env}"
}

resource "azurerm_container_registry" "my_acr" {
  name                = "myacr${replace(name_suffix, "-", "")}"
  location            = "${azurerm_resource_group.location}"
  resource_group_name = "${azurerm_resource_group.name}"
  sku                 = "Basic"
  admin_enabled       = true
} 

Here namespace value will be resolved at runtime.

Terraform version 0.12.7

1

1 Answers

10
votes

it was a silly mistake. instead of name_suffix. i should i wrote it like local.name_suffix inside the acr resource