hashicorp / hashicorp/terraform

append collection function

Open
#25,035 1 comment 0 reactions 0 assignees View on GitHub
enhancement functions
Dominant language
Go
Stars
49.7k
Forks
10.6k
Avg merge
21h 30m
Merged PRs (30d)
100

Description

### Current Terraform Version

```
v0.12.24
```

### Use-cases

It would be nice to be able to append items to a list, instead of creating an arbitrary list simply to use the `concat()` function

### Attempted Solutions

To add items to a list, you must create a new list and use the `concat()` function.

```hcl
variable "input_list" {
type = list(string)
default = ["one", "two", "three"]
}

locals {
new_value = "four"
merged_list = concat(var.input_list, [local.new_value])
}
```

### Proposal

A new `apppend()` function that takes a list and a value, and adds the value to the list.
```hcl
variable "input_list" {
type = list(string)
default = ["one", "two", "three"]
}

locals {
new_value = "four"
merged_list = append(var.input_list, local.new_value)
}
```

### References

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.