Ask questionsError in Terraform 0.12.0: This object has no argument, nested block, or exported attribute
0.12.0
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?
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