I want to manage my AWS Organization with Terraform CLI and then create some
resources in sub-accounts of my org.
I signed in to AWS with my root credentials and created an IAM user with the
AdministratorAccess policy, then I created access keys for this IAM user and put
them as the default and only profile in my ~/.aws/credentials. These are the
only credentials available on the system and Terraform is using them.
I then have this terraform code to set up my organization and sub-accounts and
then assume the role to create stuff in the sub-account:
Answering my own question, it was a silly problem that I failed to see
When creating a new aws_organizations_account it will start out with only the default regions enabled and I was trying to use var.region = "eu-south-1" which isn’t one of them.
After logging in the AWS Console and enabling the region my code started to work correctly.
@lesinigo I am getting the same error in terraform cloud :
Error: error configuring Terraform AWS Provider: IAM Role (arn:aws:iam::OMITTED:role/AWSAdmin) cannot be assumed.
How did you solve your issue ?
Would appreciate much if you could please some guidance here.
Reading this "
`When creating a new aws_organizations_account it will start out with only the default regions enabled and I was trying to use var.region = "eu-south-1" which isn’t one of them.
After logging in the AWS Console and enabling the region my code started to work correctly.
I’m now looking into how to enable my non-default region with terraform 27.
My environment is a little different I have 2 accounts in an AWS Organizations and I have an ec2 instance with an assumed role called ROLE_A in the other account I created a ROLE_B and in the trust_relationship it allows ROLE_A to do ‘sts:assumerole’ and in role_A it allows it to do ‘sts:assumerole’ in role_b in the other account but it doesn’t work I activated debug in terraform but the instance always uses role_a the assume_role parameter of main.tf seems not to be read and trying to assume the other role in the other account.