terraform plan -generate-config-out fails for schemas with nested and computed "id" attributes #35178
Labels
bug
confirmed
a Terraform Core team member has reproduced this issue
explained
a Terraform Core team member has described the root cause of this issue in code
plannable-import
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/henryrecker-pingidentity/96529224dfd95a19d58bdd1843371048
Expected Behavior
terraform plan -generate-config-out should create the HCL in generated.tf as expected, including all attribute values.
Actual Behavior
An error occurs when using an attribute named "id" that is computed in a listnested attribute. The "id" value is left out of the resulting generated HCL file. Note: A normal
terraform import
works fine. It's just theterraform plan -generate-config-out
that fails.Error:
Output generated HCL file:
Steps to Reproduce
I used a sample provider I built with terraform-plugin-framework. The provider has an
example_import_error
resource with one basictest_id
attribute, and one listnested attribute with anid
attribute in the nested object.The implementation of this resource is in this gist - https://gist.github.com/henryrecker-pingidentity/490a9ee2d0a7702463807686ff276c00
The full provider is located here (on the linked ImportBlockBug branch) - https://github.com/henryrecker-pingidentity/terraform-provider-example/tree/ImportBlockBug
Then with a locally built provider, I ran
terraform plan -generate-config-out=generated.tf
with the configuration file above.Additional Context
This does not occur with normal terraform import (
terraform import example_import_error.ex test
for example) or with normal terraform CRUD operations.This seems to specifically be related to the attribute name "id". If I change the listnested attribute to use a different string attribute name, the error goes away.
It also seems to be specific to the "id" value being computed. If not computed, the error also goes away.
References
No response
The text was updated successfully, but these errors were encountered: