Hi All,
I’ve a requirement to create an array of IAM roles for the preprod and prod env. I thought of doing something like below but not able to finally create the array. Any suggestion?
locals {
preprod_regions_list = toset([setproduct(["dev"], var.dev_regions), setproduct("qa", var.qa_regions)])
}
Here, dev_regions are [“region-1”, “region-b”]
data "aws_iam_policy_document" "policy" {
region_list = local.preprod_regions_list
iam_roles = [
for pair in region_list : {
}
]
In would like to parse the region_list and create the dynamic array of iam_roles in the below format
arn:aws:iam::var.ztnaaas_account_mapping[pair[0].key]:role/rolename-pair[1].key
Any suggestions?