From 64bdfbc98f8c1b3fc46fd68f5437e42a6bfea574 Mon Sep 17 00:00:00 2001 From: von Date: Wed, 23 Oct 2024 00:44:59 +0300 Subject: [PATCH] make lb group dynamic --- main.tf | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main.tf b/main.tf index a45ab13..1784862 100644 --- a/main.tf +++ b/main.tf @@ -47,14 +47,12 @@ resource "yandex_vpc_subnet" "subnet1" { resource "yandex_lb_target_group" "group1" { name = "group1" - target { - subnet_id = yandex_vpc_subnet.subnet1.id - address = yandex_compute_instance.vm[0].network_interface.0.ip_address - } - - target { - subnet_id = yandex_vpc_subnet.subnet1.id - address = yandex_compute_instance.vm[1].network_interface.0.ip_address + dynamic "target" { + for_each = yandex_compute_instance.vm + content { + subnet_id = yandex_vpc_subnet.subnet1.id + address = target.value.network_interface.0.ip_address + } } }