-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Unable to dereference set values #27949
Comments
The 'simple' workaround for this issue is to use the following splat expression
However, the following 'full' test case
fails with the following message:
If however the aws_instance.template block is removed or commented out, the following output is produced:
This failure is not reproducible if the for_each on the data.aws_ami objects are simplified away. |
Hi @ablackrw, thanks for reporting this. I think the underlying issue here is that the data source attribute you're referencing returns a
Compare to your expected result:
I'm not sure what your intention is with the real example. But because the set value could contain multiple block device mappings, your Terraform code has to define which of those mappings is the one you want to use as the root block device's volume size. My recommendation would be to post in the Terraform community forum about this use case, where hopefully someone with experience with this problem will be able to advise on how best to do that. That task is something that could probably be helped by the |
I think the initial test case is somewhat valid, though incorrectly structured. If the output block is replaced with the following
the actual behavior becomes
with the expected behavior becoming
The goal with the real example is to create an aws_instance object using a sub-attribute from the data.aws_ami object. In the data source documentation, it indicates that the sub-attributes can be accessed by index as shown in the 'normal' output. |
As you are seeing from these error messages, It looks like in your real example, you're only considering the case when the |
This discussion may point to a documentation or design bug in the hashicorp/aws provider. The |
That sounds correct to me! I tried to find information about this in the AWS provider docs before replying to this issue to no avail, so adding docs explaining what to expect from this set and how to use it in practice would be very valuable. |
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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
Actual Behavior
Steps to Reproduce
terraform init
terraform plan
Additional Context
The value of local.mapping is a stand-in for a data.aws_ami object (from the v3.30 hashicorp/aws provider). It may be possible to work around this issue on the provider side, but this inability to look up values from sets likely will trip people up.
References
The text was updated successfully, but these errors were encountered: