github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/terraform/testdata/plan-for-each/main.tf (about)

     1  # maps
     2  resource "aws_instance" "foo" {
     3      for_each = {
     4          a = "thing"
     5          b = "another thing"
     6          c = "yet another thing"
     7      }
     8      num = "3"
     9  }
    10  
    11  # sets
    12  resource "aws_instance" "bar" {
    13      for_each = toset([])
    14  }
    15  resource "aws_instance" "bar2" {
    16      for_each = toset(["z", "y", "x"])
    17  }
    18  
    19  # an empty map should generate no resource
    20  resource "aws_instance" "baz" {
    21      for_each = {}
    22  }
    23  
    24  # references
    25  resource "aws_instance" "boo" {
    26      foo = aws_instance.foo["a"].num
    27  }
    28  
    29  resource "aws_instance" "bat" {
    30      for_each = {
    31          my_key = aws_instance.boo.foo
    32      }
    33      foo = each.value
    34  }
    35