Let me give some context to the issue.
I'm trying to create a terraform script that deploys an AWS Organization with some accounts and also some resources in those accounts.
So, the issue is that I cant seem to be able to figure out how to create resources on multiple accounts at runetime. Meaning that I'd like to create resources on accounts I created on the same script.
The "workflow" would be something like this
- Script creates AWS Organization
- Same script creates AWS Organizations account
- Same script creates an S3 bucket on the account created
Is this a thing that is possible doing? I know one can "impersonate" users by doing something like the following.
provider "aws" {
alias = "dns"
assume_role {
role_arn = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"
session_name = "SESSION_NAME"
external_id = "EXTERNAL_ID"
}
}
But is this information something I can get after creating the account as some sort of output from the AWS-organization-account terraform module?
Maybe there is another way of doing this and I just need some reading material.