-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
allow negative indices for the element
function
#15582
Comments
+1 |
Hi @rafalcieslak! Sorry for the long silence here while we've been mostly heads-down on v0.12.0 development work. Since the behavior you are describing is complementary with the modulo it takes for positive numbers, I agree that this is a reasonable thing to implement. We require being more explicit when using the native index syntax with square brackets, but the The Terraform team at HashiCorp won't be able to work on this in the near future due to our focus being elsewhere, but we'd be happy to review a pull request if you or someone else has the time and motivation to implement it. Alternatively, if others would also like to see this implemented I'd encourage adding a 👍 upvote reaction to the original issue comment (not to this comment), which we use as one of the inputs to prioritize work for the Terraform team. Please note that the function implementations in the We're currently in an informal feature freeze period while we finish up the v0.12.0 release so we won't be able to merge a PR for this at least until after v0.12.0 final is out, but we can look at at afterwards. |
Hello @apparentlymart, |
Thank you for your continued interest in this issue. Terraform version 1.8 launches with support of provider-defined functions. It is now possible to implement your own functions! We would love to see this implemented as a provider-defined function. Please see the provider-defined functions documentation to learn how to implement functions in your providers. If you are new to provider development, learn how to create a new provider with the Terraform Plugin Framework. If you have any questions, please visit the Terraform Plugin Development category in our official forum. We hope this feature unblocks future function development and provides more flexibility for the Terraform community. Thank you for your continued support of Terraform! |
element
function
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. |
Since
element( list, index )
supports indices that are greater than the length of the list (by wrapping around the list usingmod
), it would also make sense for it to accept negative values, by wrapping around in the opposite direction.An especially useful case would be using
-1
to get the last element of a list.The text was updated successfully, but these errors were encountered: