terraform-provider-template icon indicating copy to clipboard operation
terraform-provider-template copied to clipboard

Resource 'template_file.xxx' does not have attribute 'rendered' for variable 'template_file.xxx.rendered'

Open hashibot opened this issue 8 years ago • 10 comments

This issue was originally opened by @mattsoftware as hashicorp/terraform#3417. It was migrated here as part of the provider split. The original body of the issue is below.


After modifying the template referenced with new content, terraform does not seem to be able to render my file anymore. I cannot even destroy my infrastructure to fix the issue :/


matts-air:stage1singapore matt$ terraform plan
Error configuring: 1 error(s) occurred:

* Resource 'template_file.stage_users' does not have attribute 'rendered' for variable 'template_file.stage_users.rendered'

matts-air:stage1singapore matt$ terraform destroy
Do you really want to destroy?
  Terraform will delete all your managed infrastructure.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

Error configuring: 1 error(s) occurred:

* Resource 'template_file.stage_users' does not have attribute 'rendered' for variable 'template_file.stage_users.rendered'

hashibot avatar Jun 13 '17 13:06 hashibot

This comment was originally opened by @philp as https://github.com/hashicorp/terraform/issues/3417#issuecomment-145842666. It was migrated here as part of the provider split. The original comment is below.


We experience exactly the same issue when running terraform destroy.

hashibot avatar Jun 13 '17 13:06 hashibot

This comment was originally opened by @mattsoftware as https://github.com/hashicorp/terraform/issues/3417#issuecomment-146729538. It was migrated here as part of the provider split. The original comment is below.


I dont know how to fix this without blowing my infrastructure away, I cannot seem to taint that one resource...

matts-air:stage1singapore matt$ terraform plan -module-depth=2
Error configuring: 1 error(s) occurred:

* Resource 'template_file.stage_users' does not have attribute 'rendered' for variable 'template_file.stage_users.rendered'

matts-air:stage1singapore matt$ terraform taint template_file.stage_users
The resource template_file.stage_users couldn't be found in the module root.

... I thought I could just apply that one resource to hope to get it to refresh, but no...

matts-air:stage1singapore matt$ terraform apply -target=template_file.stage_users
Error configuring: 1 error(s) occurred:

* Resource 'template_file.stage_users' does not have attribute 'rendered' for variable 'template_file.stage_users.rendered'

... I thought I would just copy the config, but if I add a new template_file with the name stage_users_2 now that one is not able to be rendered...

matts-air:stage1singapore matt$ terraform plan -module-depth=2
Error configuring: 1 error(s) occurred:

* Resource 'template_file.stage_users_2' does not have attribute 'rendered' for variable 'template_file.stage_users_2.rendered'

... I am at a loss :/

hashibot avatar Jun 13 '17 13:06 hashibot

This comment was originally opened by @mattsoftware as https://github.com/hashicorp/terraform/issues/3417#issuecomment-146729899. It was migrated here as part of the provider split. The original comment is below.


I should mention returning the original file back to what it looked like before the changes, does not make a difference, it still does not have the rendered attribute

hashibot avatar Jun 13 '17 13:06 hashibot

This comment was originally opened by @mattsoftware as https://github.com/hashicorp/terraform/issues/3417#issuecomment-146736609. It was migrated here as part of the provider split. The original comment is below.


My solution for the moment involves commenting out the line that uses the rendered template, and replace it with a line with an empty string, run apply, then put the rendered variable back, run apply again. So only the resources that use the template will be touched, but they will be modified twice instead of just the once.

hashibot avatar Jun 13 '17 13:06 hashibot

This comment was originally opened by @shanesveller as https://github.com/hashicorp/terraform/issues/3417#issuecomment-199517825. It was migrated here as part of the provider split. The original comment is below.


I wound up bumping into this through user error:

My template_file had a count, my aws_instance had a count, both based on the same variable, but the instance originally looked for a singular template resource, with the according syntax. I had to switch to using element(template_file.foo.*.rendered, count.index) where I was calling it previously.

hashibot avatar Jun 13 '17 13:06 hashibot

This comment was originally opened by @chadgrant as https://github.com/hashicorp/terraform/issues/3417#issuecomment-258585091. It was migrated here as part of the provider split. The original comment is below.


Still happening in 0.7.7 and with the new data.template_file. replacing it with empty string still allowing you to destroy it.

hashibot avatar Jun 13 '17 13:06 hashibot

This comment was originally opened by @luisdavim as https://github.com/hashicorp/terraform/issues/3417#issuecomment-307332424. It was migrated here as part of the provider split. The original comment is below.


I got this using 0.9.8, the solution was to set the vars to empty string, plan and apply and then revert them back to what it was and plan and apply again, like @mattsoftware mentioned...

hashibot avatar Jun 13 '17 13:06 hashibot

I just ran into this issue the first time I ran destroy with Terraform v0.10.6. I never got this issue with Terraform v0.8.6, but I did make other changes since upgrading to Terraform v0.10.6 a couple days ago (e.g. I was using a module instead of a local before).

Error applying plan:

1 error(s) occurred:

* local.foo: local.foo: Resource 'data.template_file.environment_config' does not have attribute 'rendered' for variable 'data.template_file.environment_config.rendered'

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

jdimatteo avatar Oct 03 '17 23:10 jdimatteo

I worked around this by not using locals.

I replaced the local with a module and that worked.

(A module with just variables and outputs can simulate locals for intermediate variables.)

jdimatteo avatar Oct 04 '17 00:10 jdimatteo

@mitchellh today I hit this error with the following:

random_id suffix_blah google_kms_keyring blah { name = blah - random_id.suffix_blah.hex } google_kms_cyrpto_key blah { name = blah random_id.suffix_blah.hex } module gke { keyring_name = google_kms_keyring.blah.name key_name = google_kms_crypto_key.blah.name }

Then I repleace both kms references in the module with the 'blah - random_id' that is used for the key names, and I get the same error, attribute 'hex' not available.

It looks to me tf is doing something funny somewhere on the ordering of the resources ?

edward2a avatar Jul 24 '19 18:07 edward2a