Currently there is a resource_aws_cloudformation_stack_set_instance
resource. The problem with this resource is that it can only create a stack set instance in one account at a time. The next problem is that stack set can only handle one operation at a time. This means that if you need to create 5 stack set instances using the same stack set, that you will have to disable parallelism for your entire terraform project. Or add dependencies between the stack set instances. Both are not desirable, we have over 30 accounts.
The AWS API, however, supports multiple account ids when creating stack set instances. I'm a bit confused as to why this was implemented with a single account id and not multiple account ids.
Allow the use of multiple account ids with the resource_aws_cloudformation_stack_set_instance
resource or create a new resource resource_aws_cloudformation_stack_set_instances
.
resource "aws_cloudformation_stack_set_instance" "backupplan_setup_stack" {
account_ids = ["123141241", "123124214", "35235234"]
stack_set_name = var.aws_backupplan_setup_stack_set_name
region = "eu-west-1"
}
An additional idea would be to support Organizational Units as well, as this is being supported in the AWS api as well.
I would be good with just the organization unit support
There is way, you can use "for_each" for multiple accounts
resource "aws_cloudformation_stack_set_instance" "config_instance"{
for_each = local.aws_accounts
account_id = each.value
region = "us-east-1"
stack_set_name = aws_cloudformation_stack_set.config.name
}
Most helpful comment
An additional idea would be to support Organizational Units as well, as this is being supported in the AWS api as well.