Created
April 8, 2022 21:43
-
-
Save lgfa29/1fc865678d5b197606bb7c0c71761339 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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