I’m using AWS.
I have one parent account.
I have many children accounts.
I have a policy in the parent, which allows IAM users to assume children accounts:
data "aws_iam_policy_document" "assume" {
statement {
sid = "AssumeIntoChildren"
effect = "Allow"
actions = [
"sts:AssumeRole"
]
resources = [
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:role/assume-into-me"
]
}
}
I can get a list of all accounts:
data "aws_organizations_organization" "all_accounts" {}
Is it possible to use for_each
to loop over data.aws_organizations_organization.all_accounts.accounts[*].id
when defining the resources
in my iam policy?
If not, I’m stuck modifying this policy every time I add an account.