You need to compare the live state of 300 Route 53 records against a desired YAML file and report drift. How do you approach it?
AdvancedScenarioAutomation scripting & CLI design
Answer
Situation read → Desired vs actual reconciliation, report-only.
What I'd do →
- Load desired records from YAML into a dict keyed by
(name, type), normalizing names (trailing dot, lowercase) and sorting values. - Fetch actual with the
list_resource_record_setspaginator, normalized the same way. - Compute set differences: missing, extra, changed (compare TTL and sorted values).
- Output a diff report (Markdown + JSON) and exit 2 if drift exists.
- Recommend moving the zone into Terraform so drift detection is
terraform plan.
Why → Normalization is the hard part; without it every record looks drifted.
Interview tip → Mention normalization explicitly; it is what separates a working diff from noise.
More on Automation scripting & CLI design
Your team has a 300-line Bash script that parses JSON with `jq`, loops over AWS accounts and retries with `sleep`. It breaks every month. Do you rewrite it in Python?BeginnerA colleague's script deletes files older than 30 days from `/var/log/app`. You are asked to review it before it goes into cron. What do you look for?IntermediateYou need a script that ops engineers run from laptops and that CI runs nightly. How do you design its interface?IntermediateA script reads a 15 GB access log to count 5xx errors per endpoint, and the box runs out of memory. How do you fix it?BeginnerYou must run the same Python automation on 40 servers that have Python 3.6, 3.9 and 3.12. What do you do?IntermediateA cron job that runs a Python script fails silently. Nobody noticed for two weeks. How do you make sure that never happens again?Intermediate