cf-wait: stop refreshing your browser after a deploy
I push a blog post, the GHA workflow syncs to S3 and creates a CloudFront invalidation, and then I sit there refreshing the browser for 60 seconds wondering if it’s live yet. The invalidation will complete. I know that. I just want to know when.
AWS already has a waiter for this:
aws cloudfront wait invalidation-completed \
--distribution-id E1XXXXXXXXXXXXX \
--id IATO2M6CON87VGDVG0LPV1IAT1
Two problems. I never remember the distribution ID — I have four sites across two accounts. And I never have the invalidation ID because the workflow created it, not me.
cf-wait wraps the two things I forget into a site name lookup:
$ cf-wait ferkakta.dev
Waiting for ferkakta.dev IB5NHJG45IDUU3LXHUGDDQBBI4...
InProgress...
✓ ferkakta.dev IB5NHJG45IDUU3LXHUGDDQBBI4 completed
It finds the most recent invalidation automatically. If that invalidation completed more than five minutes ago, the CDN already caught up and something else is wrong — so it creates a fresh one and waits for that instead:
$ cf-wait ferkakta.dev
Most recent invalidation (IATO...) completed 23m ago. Creating a fresh one...
Created: IAVRT13BVI0KIXZDKPZ94G9W9U
Waiting for ferkakta.dev IAVRT13BVI0KIXZDKPZ94G9W9U...
✓ ferkakta.dev IAVRT13BVI0KIXZDKPZ94G9W9U completed
The whole thing is a bash associative array mapping site names to distribution IDs. Adding a site is one line. cf-wait all checks every site at once — useful after a deploy weekend when you’ve pushed to three repos and lost track of which ones propagated.
The value isn’t the polling loop — aws cloudfront wait does that. The value is never typing a distribution ID again.
The script: cf-wait