Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lgfa29
Created April 8, 2022 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgfa29/1fc865678d5b197606bb7c0c71761339 to your computer and use it in GitHub Desktop.
Save lgfa29/1fc865678d5b197606bb7c0c71761339 to your computer and use it in GitHub Desktop.
provider "local" {}
variable "servers" {
type = map(object({
ip = string
}))
}
resource "local_file" "vms" {
for_each = var.servers
filename = "vm-${each.key}"
content = each.value.ip
}
output "ips" {
value = [for v in local_file.vms : v.content]
}
servers = {
"server-1" = {
ip = "10.0.0.2"
}
"server-2" = {
ip = "10.0.0.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment