-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Sum function for interpolation #17239
Comments
I concur that this would be useful @rf-vivanovs |
While there is not a |
v0.12 is out, and it looks like this was not included, is that correct? |
Struggling to overcome this myself and it feels like it should be so simple. Is there really no other way of doing this in version 0.12.2 ?? for loop, create new value, add value to new and repeat Would welcome your guidance. |
This would be a really useful feature to have 👍 |
Hi all! 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 we'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 don't leave new comments with 👍 and similar upvote messages, because they just create noise for those who are subscribed to the issue, and don't create any signal that the Terraform team can report on.) |
A little workaround that works in 0.12:
|
Failed if values will be more 1024 |
The 1024 limit makes this workaround inappropriate for my use case, the goal of which is to calculate the total budget of a subset of an AWS organization's accounts. |
here's my egregious hack: # this is an egregious hack, because terraform doesn't have sum()...
# the largest number that can be added to the sum is the length of (long)
# make a 16K long string -- this should be as long as your largest expected number
long_str = format("%16384s","")
nums = [ 1, 2, 3, 10 ]
sum = length(join( "", [for n in local.nums: substr(local.long_str,0,n)])) |
Can someone review that please? #24551 |
The |
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. |
Hello,
I have been looking at various interpolation function in Terraform and were not able to find basic
sum
function.What I have is a list of ints: [5, 0, 1, 2] which specify number of nodes I need to create (They are the same type). What I would like to have is just a function that can just sum the list of ints.
Example:
Would be a really nice function to have.
The text was updated successfully, but these errors were encountered: