I’m using a for_each
statement in a resource like:
resource "my_resource_type" "my_resource_name"
that creates several resources with names formatted like:
my_resource.my_resource_name["${each.value}-2"]
…resulting with values like:
resourceA-1
resourceA-2
resourceA-3
resourceB-1
resourceB-2
resourceB-3
I want to use another loop in another resource to reference these resource id
s.
ids = [
resourceA-1.id
resourceA-2.id
resourceA-3.id
]
It seems as simple as:
my_resource_type.my_resource_name.${each.value}-1.id
my_resource_type.my_resource_name.${each.value}-2.id
my_resource_type.my_resource_name.${each.value}-3.id
But many variations on this with quoting don’t seem to pass my linter or otherwise fail at plan time with some syntax error.
Is there a way to reference the resource like this?