Interview Prep/Ansible/AWX, AAP and Cloud Integration

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_ec2 source per account (or per account group) using iam_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.

All Ansible questions Roadmap: Ansible

More on AWX, AAP and Cloud Integration