-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Function keys()
to return set instead of list
#24409
Comments
Hi @aaronsteers Unfortunately we can't change the return type of Can you help me better understand the use case here? The |
@jbardin - I completely understand this could potentially be a breaking change. For my info, are there many cases where Another specific use case is where, in a Can you speak a little more to how much would break - or I guess, what are the rules around implicit |
Thanks for the feedback @aaronsteers! You're right that a I think the impact would be minimal, we just want to make sure there is a good reason to make any impact at all. Looking at the |
Awesome - thanks for the quick reply. For my part, I agree the relative priority of the change is minor. And to minimize risk, this might make the most sense as part an upcoming major release, where some number of potentially-breaking changes are already expected rather than a minor release. Either way, I still think as a minor enhancement, it seems like a good overall investment and I am glad to have it logged and potentially able to get incorporated into the roadmap (whatever that might look like). |
Hi @aaronsteers I've had a little time to look into this and I see a couple problems. The other point is that the Because not passing the full map value to Thanks again for the request! |
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. |
Current Terraform Version
Use-cases
The primary use case this affects is when using the keys from a map variable as input to a for_each loop. Although the resulting list is unique and would be correctly defined as a set. However, since the compiler cannot detect that the result of keys() is in fact a unique set, terraform throws an error that for_each can only accept map or set as input.
Attempted Solutions
for_each = toset(keys(var.my_map))
Proposal
Proposed solution is that
keys()
would always return aset
object instead oflist
.References
n/a
The text was updated successfully, but these errors were encountered: