Closed marc-poljak closed 1 week ago
Hi @marc-poljak, thanks for filing this. Unfortunately, what you are attempting to do here isn't possible.
The count attribute you have in your data source is always going to return 0, even if the data source does actually exist. You can't self-reference attributes in this way within Terraform as it has to load the data source before the attributes are available but it requires all the attributes to be available before it can load the data source.
However, Terraform definitely shouldn't be crashing in this case but reporting an error that informs you this kind of referencing isn't possible. I had thought this was fixed in https://github.com/hashicorp/terraform/issues/35038, but it seems an edge case must have been missed so I'll investigate to see exactly why the check we added previously isn't catching this instance of self-reference.
Hi @liamcervante thanks for the answer and the explanation. I hope I could help a little bit with filing the crash report.
Terraform Version
Terraform Configuration Files
Debug Output
the log trace file is empty!
Expected Behavior
Actual Behavior
terraform crash after terraform plan
Steps to Reproduce
terraform init terraform plan
Additional Context
References
no