Interview Prep/Python for DevOps/AWS automation with boto3

You must audit 40 AWS accounts in an Organization from one script. How do you handle credentials?

AdvancedScenarioAWS automation with boto3
Answer

Situation read → Cross-account access, centrally.

What I'd do →

  1. Deploy an AuditReadOnly role to every account via StackSets or Terraform, trusting only a role in the security/tooling account.
  2. List accounts with organizations.list_accounts (paginator) from the management or delegated admin account.
  3. For each account, sts.assume_role into the audit role and build a fresh Session from the returned credentials.
  4. Run accounts in parallel with a bounded pool; catch AccessDenied per account and report rather than abort.

Why → One trust path, least privilege, no keys in any account.

Interview tip → Mention ExternalId only matters for third-party access; inside an org, condition on aws:PrincipalOrgID.

All Python for DevOps questions Roadmap: Python for automation

More on AWS automation with boto3