New Delhi, India
BlogMarch 5, 2025

Multi-Account AWS Automation: IAM Role Assumption at Scale

AWS STS
IAM Security
Multi-Account AWS
Confused Deputy
Cloud Security
Harjot Singh Makkar
Multi-Account AWS Automation: IAM Role Assumption at Scale
If you need to query inventory, apply configuration, or collect metrics across a large AWS estate, the naive approach is to maintain credentials for each account. This creates a credential management problem that scales with the number of accounts - hundreds of access keys to rotate, audit, and secure.
Deep-Dive Case Study: For the complete production architecture, fleet inventory dashboard, and FinOps zombie resource reclamation across 400+ accounts, read Automating Cloud Inventory Across 400+ AWS Accounts.
IAM role assumption solves this. A single automation account holds a minimal identity. Each target account has a role that trusts that identity. The automation assumes that role when it needs to work in a target account, operates for the duration of the task, and releases the temporary credentials when done.
Automation Account (IAM User/Role)
  │
  ├── AssumeRole → Account A (arn:aws:iam::111111111111:role/AutomationRole)
  │                └── temporary credentials → scoped to Account A
  │
  ├── AssumeRole → Account B (arn:aws:iam::222222222222:role/AutomationRole)
  │                └── temporary credentials → scoped to Account B
  │
  └── AssumeRole → Account C ...
Each temporary credential set has a maximum lifetime (typically 1 hour). After the automation completes its work in that account, the credentials expire automatically. There are no long-lived credentials to rotate or secure per account. In each target account, the AutomationRole has a trust policy that allows the automation account identity to assume it: The ExternalId condition prevents confused-deputy attacks, where a third party tricks your automation into assuming a role on their behalf. The automation executor's own credentials shouldn't be static environment variables. Use a secrets manager (HashiCorp Vault, AWS Secrets Manager) to provide the base identity: Containerize the automation and schedule it as a Kubernetes CronJob for reliable recurring execution:
  1. No long-lived per-account credentials: Role assumption provides temporary, scoped access
  2. ExternalId for trust boundary: Prevents confused-deputy attacks
  3. Handle partial failures gracefully: One account failing shouldn't stop collection for others
  4. Schedule through Kubernetes CronJobs: Reliable, observable, and auditable execution
  5. Integrate secrets management: Base identity credentials should come from a secrets manager, not environment variables
Scaling this pattern from 10 accounts to 400+ accounts requires no architectural changes - just more entries in the account list.
Share this post: