Interview Prep/Python for DevOps/AWS automation with boto3

You need to rotate IAM access keys older than 90 days for service users and notify owners. What do you build?

AdvancedScenarioAWS automation with boto3
Answer

Situation read → Keys should not exist at all for most services; the script is a stopgap.

What I'd do →

  1. Get the credential report (iam.generate_credential_report, poll, then get_credential_report, parse CSV) for key age and last used.
  2. Flag keys older than 90 days; for unused keys (no last_used_date in 90 days) deactivate, then delete after a grace period.
  3. Notify owners via the Owner tag on the user, with a deadline.
  4. Track the real fix: move each workload to roles (OIDC, instance profiles, IRSA) and delete the user.

Why → The credential report gives everything in one call instead of N list_access_keys calls.

Interview tip → Say the goal is zero long-lived keys; rotation is risk reduction, not the solution.

All Python for DevOps questions Roadmap: Python for automation

More on AWS automation with boto3