Taula de continguts

Chapter 5: Terraform tips and tricks

loops

count

for_each

variable "bla_names" {
  type    = map(string)
  default = {"green" = "bla_green","yellow" = "bla_yellow","red" = "bla_red"}
  #default = map("green","bla_green", "yellow","bla_yellow", "red","bla_red")
}
resource "blablabla" "blablabla_name" {
for_each = toset(var.bla_names)
name  = each.value
}

for

for string

conditionals

Pendiente

Pos 3500 aprox

count

variable "booleana" {
  type = bool
}
resource "resource" "resource_name" {
  count = var.booleana ? 1 : 0
  ...
}
variable "cadena" {
  type = string
  default = "aaa"
}
resource "resource" "resource_name {
  count = format("%.1s",var.cadena) == "a" ? 1 : 0
}

for_each

if string

Zero-Downtime Deployment

terraform gotchas