Python Automation¶
Shell is the right tool for gluing commands together. When a task needs to call APIs, paginate, retry, parse structured data, or be tested properly, Python is usually the next step. This track teaches Python the way operations teams use it: small, reliable tools that run unattended in cron jobs, CI pipelines, and Lambda functions.
What You'll Learn¶
- How to set up a Python project with reproducible dependencies using
uv - How to build command-line tools that run other programs safely
- How to call HTTP APIs with timeouts, retries, and pagination
- How to automate AWS with boto3, safely and at scale
- How to read and write YAML, JSON, and templated config files
- How to lint, type-check, test, and package your tools
Prerequisites¶
Basic Python syntax — variables, functions, loops, dictionaries, and exceptions. If you're new to Python, work through the official Python tutorial first. Examples use Python 3.14 and work on 3.12 and newer.
Read in This Order¶
- Project Setup — installing Python with
uv, virtual environments,pyproject.toml, lock files, and project layout - CLI Tools and subprocess — Typer and argparse, running commands safely, logging, and exit codes
- Working With HTTP APIs —
httpx, timeouts, retries with backoff, pagination, authentication, and rate limits - AWS Automation With boto3 — sessions and credentials, paginators, waiters, error handling, and real cleanup scripts
- Files, Config, and Templates —
pathlib, JSON, YAML, TOML, Jinja2, and atomic writes - Testing, Linting, and Packaging — pytest, mocking HTTP and AWS, Ruff, mypy, CI, and installable tools
What You'll Build¶
By the end of the track you'll have an opsctl command-line tool that:
- Checks service health endpoints with retries and a clear exit code
- Finds unattached EBS volumes and old snapshots across AWS regions, with a dry-run mode
- Renders environment-specific configuration from YAML and a template
- Has tests that run without network access or an AWS account
Next¶
Start with Project Setup.