I want to map a list of object in terraform to get a list of single values.
In javascript this would look something like this.
[{a: 1}, {a: 2}].map(item => item.a)
// [1, 2]
How can I do this in terraform?
locals {
items = [for item in [{a: 1}, {a: 2}]: item.a]
}
If we output local.items we get the following:
items = [
1,
2,
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With