Terraform plan giving error Unsupported attribute for outputs

Hi All,

While executing the terraform plan, I am getting following error.

Error: Unsupported attribute

│ on runners.tf line 18, in data “template_file” “init_runner”:
│ 18: dynatrace_oneagent_host_group = data.terraform_remote_state.resources_runners_project.outputs.resources_runners_project_id
│ ├────────────────
│ │ data.terraform_remote_state.resources_runners_project.outputs is object with no attributes

│ This object does not have an attribute named “resources_runners_project_id”.

Whereas If I check the state for this attribute is gives below output with required details.

$ terraform state show data.terraform_remote_state.resources_runners_project

data.terraform_remote_state.resources_runners_project:
data “terraform_remote_state” “resources_runners_project” {
backend = “gcs”
config = {
bucket = “ren-xxxxxx-resource-tf-ope-xxxx”
prefix = “terraform/state/runners/resources/project”
}
outputs = {
default_identity_with_no_permissions = {
account_id = “sa-with-no-permissions”
description = “A Service Account with no permissions, attached to the GCE instances so they can login to Vault”
disabled = false
display_name = “sa-with-no-permissions”
email = “sa-with-no-permissions@irn-xxxxxx-xxxxx-xxxxx-230.iam.gserviceaccount.com
id = “projects/irn-xxxxxx-xxxxxx-xxxxx-230/serviceAccounts/sa-with-no-permissions@irn-xxxxxx-xxxxx-xxxxxx-230.iam.gserviceaccount.com”
name = “projects/irn-xxxxxx-xxxxx-xxxxxx-230/serviceAccounts/sa-with-no-permissions@irn-xxxxxx-xxxxx-xxxxxx-230.iam.gserviceaccount.com”
project = “irn–xxxxxx-xxxxx-xxxxxx-230”
timeouts = null
unique_id = “1067xxxxxxxxxxx448”
}
resources_runners_project_id = “irn-xxxxxx-xxxxx-xxxxxx-230”
}
workspace = “xxxxxxxx”
}

Terraform backend is pointing to correct gcs bucket. Terraform state file shows version 1.2.6 and when I execute terraform state pull then it shows version 1.5.6.

Kindly advice

Hi @ganesh-pawade,

The values you see in terraform show are remants of the most recent successful apply. If you ask Terraform to create a new plan then it will discard those values and fetch the current data from the remote source to use instead.

It seems that for some reason your current remote state doesn’t include any output values. To confirm you’ll need to use terraform show in whatever configuration that remote state belongs to, instead of in the configuration that depends on it.

Some state storage backends also treat a missing state object as if it were an empty state object, so if your remote state configuration isn’t correct or you are using the wrong credentials to access it then that could also potentially cause this symptom.