Hi all
Seems to have some limitations in the new loop feature for module… but I don’t really understant why
I have a map with informations about some accounts
Now… I want to create a module to deploy, for example, a SQS Queue in each account.
Code example in my module :
provider "aws" {
region = var.region
profile = var.profile
assume_role {
role_arn = format("arn:aws:iam::%s:role/%s", var.account_id, var.role_name)
session_name = "newsession"
}
}
resource "aws_sqs_queue" "test" {
name_prefix = "thequeue"
}
And so, in my root configuration, I try to loop over my map and call my module for each account infos :
module "setup" {
source = "./modules/setup"
for_each = local.account_map
profile = "myprofile"
region = "eu-west-1"
account_id = each.value.id
role_name = var.iam_cross_role_name
}
But terraform returns this error :
Module “setup” cannot be used with count because it contains a nested provider
configuration for “aws”, at modules\setup\provider.tf:1,10-15.This module can be made compatible with count by changing it to receive all of
its provider configurations from the calling module, by using the “providers”
argument in the calling module block.
I really don’t understand why defining a provider in a module cause a problem for the loop feature ?
A reason ? a solution ?
Thanks you very much