Interview Prep/Python for DevOps/AWS automation with boto3

You must export all CloudWatch alarms in an account to a YAML file for review. How do you build it?

BeginnerScenarioAWS automation with boto3
Answer

Situation read → Read-only export.

What I'd do →

  1. Paginate describe_alarms (metric and composite alarms).
  2. Select relevant fields (name, metric, threshold, comparison, actions, state).
  3. Convert datetimes to ISO strings, then yaml.safe_dump(data, sort_keys=False).
  4. Commit the YAML to a repo so changes show up as diffs over time.

Why → A versioned export turns an opaque console setting into reviewable config.

Interview tip → Suggest managing alarms as code (Terraform) as the next step.

All Python for DevOps questions Roadmap: Python for automation

More on AWS automation with boto3