Multiple accounts and aws providers

Hi

First time posting - I have a situation - and I don’t know enough of the terminology to search properly for the answer.

I have 20 AWS accounts and I’d like to create a centrally managed Transit gateway in AWS. This part I can do - all ok here. When I need to create TGW associations in multiple accounts, the way I found this was to use multiple providers for AWS and alias them:

provider “aws” {
alias = “account1”
region = “eu-west-1”
allowed_account_ids = [“72938479233”]
assume_role {
role_arn = “arn:aws:iam::72938479233:role/terraform”
}
}

provider “aws” {
alias = “account2”
region = “eu-west-1”
allowed_account_ids = [“72938479233”]
assume_role {
role_arn = “arn:aws:iam::72938479233:role/terraform”
}
}

I have 20 account and probably more to come. How can I use a Map here instead of each account listed?

Can I create a local data bundle (say in YAML) and then use this to variablise the AWS alias’s

Any thought? Am I on the wrong track?

Many Thanks
Tag