Aquesta és una revisió antiga del document
Chapter 5: Terraform tips and tricks
loops
count
- usage:
resource "blablabla" "blablabla_name" { count = 3 name = "bla${count.index}" }
- result: 3 elements ([0],[1],[2])
- with
length()
:variable "bla_names" { type = list(string) default = ["bla_green","bla_yellow","bla_red"] resource "blablabla" "blablabla_name" { count = length(var.bla_names) name = bla_names[count.index] }
- output
- [#]
- [*]
- each element is assigned to their index in state, deletes o modifications implies «move» all elements after that.
- only usable for resources, no inline blocks
for_each
for
for string