I have setted up two providers (2 aws accounts), I want to launch an ec2 instance on each of the accounts without having to repeat code.
I tried using loops with count and for_each but no luck.
variable "providers" {
default = [
"aws.dev",
"aws.qa"
]
}
resource "aws_instance" "test" {
for_each = toset(var.providers)
ami = "ami-0dc9a8d2479a3c7d7"
instance_type = "t2.micro"
provider = each.value
}
I got the next error:
Error: provider.each: no suitable version installed version requirements: "(any version)" versions installed: none
I tried similar code iterating over other values like ami's, instance types and it works.
I'm not sure if there's something I'm not seeing or iteration over providers it's not supported.
Any idea or workaround for this? Thanks.