Terraform - A reference to resource type must be followed by at least one attribute access, specifying the resource name

18,633

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

Share:
18,633
vashishth
Author by

vashishth

I am a JEE application developer, where i mostly work on middleware technologies such as, JMS, Mule ESB, Fuse ESB. My GitHub handle - https://github.com/rvashishth

Updated on June 18, 2022

Comments

  • vashishth
    vashishth almost 2 years

    I am trying to use terraform string function and string concatenation on a terraform tfvars variable. but when run the terraform plan it through the 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

  • Ikar Pohorský
    Ikar Pohorský over 4 years
    You saved my day! Same mistake here ;)