David Ha
David Ha

Reputation: 327

Is is possible to use for-each with provider alias

I have multiple configurations for a provider, so I defined different provider aliases. I then have another resource that I need to create for each provider. So instead of defining each resource individually, I tried to use for-each.

However, when it comes to set the "provider" property of the resource, I can't get Terraform to recognize variables, or functions, or for-each. Example:

Suppose I have these provider aliases: "vendor.alias1", "vendor.alias2"

I am trying to define something like this:

resource vendor_resource_type "my_resource_list" {
    for-each = toset(["alias1","alias2"])
    ...
    provider = vendor."${each.key}"
}

I also tried to use lookup function (e.g provider = lookup(a map of provider aliases)) to no avail.

Is this even possible with Terraform?

Upvotes: 0

Views: 479

Answers (0)

Related Questions