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 + } } }