Friday, January 18, 2013

CloudFront Invalidation of single or multiple files via Command Line tool

Recently, i implemented a pull model on Amazon CloudFront for one of our high traffic servers. Our system runs a few services which update existing files at random intervals with new content as well as generate multiple new files. For the new files not present on CloudFront, the pull model will take care of it but what about the existing files which got updated?
These files can be updated any time and there is no predefined timer which sets the update interval. I wanted a simple and reliable solution.I ended up writing my own tool:

CloudFront Invalidator Daemon

which is written in PHP. It uses a base helper class CloudFront-PHP-Invalidator written originally by  Alexsandar and heavily modified by me. You can visit his website

Using a command line tool becomes very convinient in a situation like this where all services can call this tool and pass the filenames they want to invalidate and this tool will take care of the rest. It will also write a log file which can be monitored by administrator for debugging purposes.

Details about system requirements, installation etc are given on the project page above. I hope this tool proves helpful for fellow developers out there. Enjoy!

No comments:

Post a Comment