New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference nested fields in other resources #412
Comments
I created a small reproducible repo here |
Hi @marcoandredinis 👋 Thank you for raising this and sorry you ran into trouble here. I have two clarification questions:
Thanks so much. |
By the way, thank you for the easy reproduction. I was able to generate TRACE logging for everything with that repository and running: $ TF_ACC=1 TF_LOG=TRACE TF_ACC_LOG_PATH=/tmp/test.txt go test -count=1 -run='TestAccExampleResource' -v ./internal/provider
=== RUN TestAccExampleResource
example_resource_test.go:10: Step 1/1 error: Error running pre-apply refresh: exit status 1
Error: Unsupported attribute
on terraform_plugin_test.tf line 9, in resource "scaffolding_example" "test2":
9: name = scaffolding_example.test.metadata.name
This value does not have any attributes.
--- FAIL: TestAccExampleResource (0.11s) Gist of TRACE logging: https://gist.github.com/bflad/1fa2b2a3fd92eabb6596f6b1dfa853e7 |
Hey @bflad So, the version is
This also happens when running It's my understanding that you were able to reproduce the issue. name = (scaffolding_example.test).metadata.name |
Hi @marcoandredinis 👋 I was able to validate that using the parenthesis in the configuration reference does indeed workaround the error. From the TRACE logging, it appears this error is coming from Terraform itself while attempting to validate the Terraform configuration. Given that, I have raised hashicorp/terraform#31527 in their issue tracker to follow up further on this. I would personally expect Terraform in this situation to either "just work" or provide a more helpful error message. 👍 I'd like to keep this issue open here in case there happens to be anything we're doing wrong on our side, or in case others may run into this issue until it is hopefully resolved in some form in Terraform itself. Thanks again for your work here! |
There is now a proposed fix upstream: hashicorp/terraform#31532. If you're feeling really adventurous, you can try building Terraform using that PR branch to see how it behaves or we can wait until this gets released into a 1.2.x patch to verify it. 😄 |
It does seem to work as expected 👍 marco@lenix ~/p/terraform-provider-scaffolding-framework (main)> terraform version
Terraform v1.2.5
on linux_amd64
Your version of Terraform is out of date! The latest version
is 1.2.6. You can update by downloading from https://www.terraform.io/downloads.html
marco@lenix ~/p/terraform-provider-scaffolding-framework (main)> make testacc
TF_ACC=1 go test ./... -v -timeout 120m
? github.com/hashicorp/terraform-provider-scaffolding-framework [no test files]
=== RUN TestAccExampleResource
example_resource_test.go:10: Step 1/1 error: Error running pre-apply refresh: exit status 1
Error: Unsupported attribute
on terraform_plugin_test.tf line 9, in resource "scaffolding_example" "test2":
9: name = scaffolding_example.test.metadata.name
This value does not have any attributes.
--- FAIL: TestAccExampleResource (0.11s)
FAIL
FAIL github.com/hashicorp/terraform-provider-scaffolding-framework/internal/provider 0.117s
FAIL
make: *** [GNUmakefile:6: testacc] Error 1 marco@lenix ~/p/terraform-provider-scaffolding-framework (main)> terraform version
Terraform v1.3.0-dev
on linux_amd64
marco@lenix ~/p/terraform-provider-scaffolding-framework (main)> make testacc
TF_ACC=1 go test ./... -v -timeout 120m
? github.com/hashicorp/terraform-provider-scaffolding-framework [no test files]
=== RUN TestAccExampleResource
--- PASS: TestAccExampleResource (0.34s)
PASS
ok github.com/hashicorp/terraform-provider-scaffolding-framework/internal/provider 0.342s |
The fix for this has been merged upstream in Terraform core and will release with version 1.2.7 and the next 1.3.0 pre-release. 👍 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Module version
Relevant provider source code
Slightly modified version of the https://github.com/hashicorp/terraform-provider-scaffolding-framework
This version adds two extra fields:
Terraform Configuration Files
The following fails to run with
Debug Output
Error when running Acceptance Tests
Expected Behavior
It was expected that this code ran without any issues
Actual Behavior
Fails with error above
Steps to Reproduce
Clone
https://github.com/hashicorp/terraform-provider-scaffolding-framework
Add the schema above to the
example_resource.go
Change
example_resource_test.go
andtestAccExampleResourceConfig
with the config aboveYou must also replace the Steps list with this single step:
Run
make acctest
Workaround
If you change
name = scaffolding_example.test.metadata.name
toname = (scaffolding_example.test).metadata.name
everything works as expectedReferences
The text was updated successfully, but these errors were encountered: