profile
viewpoint

Ask questionsError in Terraform 0.12.0: This object has no argument, nested block, or exported attribute

Terraform Version

0.12.0

Issue

Hi, when I run terraform plan on one of the config files, I get the following error

Error: Unsupported attribute

  on main.tf line 16, in module "project_01":
  16:   folder_id = "${data.terraform_remote_state.folders.folder_shared_id}"

This object has no argument, nested block, or exported attribute named
"folder_shared_id".

make: *** [plan] Error 1

Here is the main.tf file

data "terraform_remote_state" "folders" {
  backend = "local"
  config = {
    path = "../../folders/terraform.tfstate"
  }
}
...
<extraneous-code>
...
module "project_01" {
  source = "<path-to-module>"

  project_name = "network"
  folder_id = "${data.terraform_remote_state.folders.folder_shared_id}"
}

However, that attribute is present in the terraform.tfstate file


$ cat terraform.tfstate
{
  "version": 4,
  "terraform_version": "0.12.0",
  "serial": 9,
  "lineage": "76c68f13-3a49-4db0-2a95-84ef9610cefa",
  "outputs": {
    "folder_test1_id": {
      "value": "folders/***",
      "type": "string"
    },
    "folder_test2_id": {
      "value": "folders/****",
      "type": "string"
    },
    "folder_shared_id": {
      "value": "folders/****",
      "type": "string"
    }

This used to work in Terraform 0.11.13 but broke in Terraform 0.12.0. Any ideas why this is happening?

hashicorp/terraform

Answer questions ameyaptk

terraform 0.12upgrade fixed the config file by fixing the first class expressions and the error disappeared. First class expressions- https://www.hashicorp.com/blog/terraform-0-12-preview-first-class-expressions

useful!

Related questions

failed to save provider manifest: open .terraform/plugins/linux_amd64/lock.json: permission denied hot 4
The argument "host" is required, but no definition was found. hot 3
Unable to run 0.12upgrade hot 3
Module cannot find alias AWS provider in 0.12.0 hot 3
Error: Invalid template interpolation value hot 2
Terraform v0.11.1 : Error downloading modules: Error loading modules: open .terraform/modules/3f10921295c292995128e9e36eb: no such file or directory hot 2
MalformedPolicyDocument: Policy document should not specify a principal. hot 2
Feature Request - Allow list/array in 'query' in 'external' data source hot 2
Terraform provider downloads fail with TLS handshake timeout hot 2
'terraform init' failed with 'Registry service unreachable.' error hot 2
for_each attribute for creating multiple resources based on a map hot 2
`Unreadable module directory` error is not clear for nested modules hot 2
Provider Development: Expected type 'string', got unconvertible type '[]interface {}' - with complicated block hot 2
"Error: Provider configuration not present" when aliased provider is used hot 2
Error loading state: state snapshot was created by Terraform v0.12.7, which is newer than current v0.12.6 hot 2
Github User Rank List