How do you run Ansible across many AWS accounts?
AdvancedProductionAWX, AAP and Cloud Integration
Answer
One automation identity in a central account, assuming a narrowly scoped role in each target account.
- Inventory: one
aws_ec2source per account (or per account group) usingiam_role_arn, with keyed groups that include the account so names never collide. - Modules: pass the assumed-role credentials from
amazon.aws.sts_assume_role, or use named profiles in the EE.
# inventories/aws/prod-payments.aws_ec2.yml
plugin: amazon.aws.aws_ec2
iam_role_arn: arn:aws:iam::222233334444:role/ansible-inventory-read
regions: [ap-south-1, eu-west-1]
keyed_groups:
- key: tags.role
prefix: role
compose:
aws_account: "'prod-payments'"
Keep the cross-account roles read-only for inventory and separate from the roles that can change things. In AWX, one inventory source per account makes sync failures easy to pin down.
More on AWX, AAP and Cloud Integration
AWX or Red Hat Ansible Automation Platform: what is the difference and what do you pay for?BeginnerWhat are the core objects in AWX and how do they fit together?BeginnerHow do you manage AWX configuration as code?IntermediateHow do custom credential types work in AWX?AdvancedHow do you connect AWX to an external secrets manager?IntermediateHow do you trigger AWX jobs from CI or other systems?Intermediate