Skip to content

Sum function for interpolation #17239

@rf-vivanovs

Description

@rf-vivanovs

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:

variable "key_list" {
  type = list
  default = [5, 0, 1, 2]
}
resource "instance" "vm" {
  count                       = "${sum(key_list)}"
}

Would be a really nice function to have.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions