@davidcsi wrote:
Fairly new to terraform, but loving it!
I need to create mulitple healthcheck with different configuration each.
for instance:
say i have 2 servers that need to have HC:
ip_address = "1.2.3.4" hc_name = "server1" hc_port = "80" ip_address = "4.3.2.1" hc_name = "server2" hc_port = "88"
I want to use only one tf, meaning i would like to loop through the servers, something like:
variable "servers" { type = list default = [ "server1", "server2" ] } variable "server1" { type = map(string) default = { ip_address = "1.2.3.4" hc_port = "80" } variable "server2" { type = map(string) default = { ip_address = "4.3.2.1" hc_port = "88" }
and do something like:
resource "aws_route53_health_check" "prod-hc" { for s in servers: ip_address = lookup(s,"ip_address") type = "HTTP" port = lookup(s,"port") }
Is this possible at all?
Many thanks!
Posts: 2
Participants: 2