Reputation: 276
Consider the following resource:
resource "type" "myspecialresource"
{
for_each = toset(["some thing", "some other thing"])
}
What do I need to add to this resource to be able to refer to it by string later on?
So, for example, I know to reference the second instance of this resource later on I can do:
type.myspecialresource[1]
, but I'd like to reference it like so instead:
type.myspecialresource["some thing"]
Upvotes: 1
Views: 158
Reputation: 239000
type.myspecialresource["some thing"]
that's how it will work. type.myspecialresource[1]
is for when you use count
. Since you are using for_each
, you have to use type.myspecialresource["some thing"]
.
Upvotes: 2