I’m building a service which will be multi-region in AWS, but will be identical across those regions. Since Terraform will generally only handle AWS regions in the provider block as opposed to individual resources, I originally planned to have various aliased AWS providers, and have my resources use a count argument with the provider name as a variable from a list.
Unfortunately, it appears that because the provider name is not treated as a string, you can’t have anything other than provider.alias
with no quotes and no functions of any sort after the provider =
argument. What’s more, the provider definition itself can’t use count
or for_each
or anything like that, so I can’t create a list variable to only define appropriate providers on a per-environment basis.
I really don’t want to replicate code for every region or script this out- it would violate our standards and disrupt our workflow. This can’t be an uncommon problem, but so far I haven’t found any interesting solutions to it. Any ideas?