github.com/hugorut/terraform@v1.1.3/src/terraform/testdata/apply-destroy-outputs/main.tf (about)

     1  data "test_data_source" "bar" {
     2    for_each = {
     3      a = "b"
     4    }
     5    foo = "zing"
     6  }
     7  
     8  data "test_data_source" "foo" {
     9    for_each = data.test_data_source.bar
    10    foo = "ok"
    11  }
    12  
    13  locals {
    14    l = [
    15      {
    16        name = data.test_data_source.foo["a"].id
    17        val = "null"
    18      },
    19    ]
    20  
    21    m = { for v in local.l :
    22      v.name => v
    23    }
    24  }
    25  
    26  resource "test_instance" "bar" {
    27    for_each = local.m
    28    foo = format("%s", each.value.name)
    29    dep = each.value.val
    30  }
    31  
    32  output "out" {
    33    value = test_instance.bar
    34  }