Automatically trigger CDN purge on S3 change

Shalom Carmel Chief Information Officer at GlobalDots
2 Min read

A CDN requires an origin server, which can be a S3 bucket. s3-trigger-purge-cdn are python scripts that run as Lambda functions, and are triggered by file uploads to the bucket. Once triggered, the Lambda function will attempt to purge the old file from the CDN cache. Currently supported CDN vendors:

How One AI-Driven Media Platform Cut EBS Costs for AWS ASGs by 48%

How One AI-Driven Media Platform Cut EBS Costs for AWS ASGs by 48%
  • Akamai
  • Cloudflare
  • Edgecast
  • Fastly
  • Highwinds

Standalone Legacy mode

  • Edgecast
  • Akamai
  • Highwinds

While I started as a project with separate parts for each CDN vendor, the standalone parts will not be maintained anymore.

Features:

  • Python based: Easy to set up and maintain
  • Uses Lambda environment variables: Modify the environment variables to modify the Lambda behavior
  • purge or load: On Edgecast, you can decide whether to purge from the edge or load onto the edge

Environment variables

Environment variables will be loaded only at the Lambda cold start

  • debug <true|false>
  • config_file defaults to multicdn.config.yml

General Usage

  1. Install and configure Python, pip and Boto3
  2. In the project directory, run the following command: pip install -r requirements.txt -t . This is in order to be able to create a full deployable package for Lambda
  3. Update the config files. There is a master YAML file, but credentials can also be managed in the config.py files in each vendor’s folder.
  4. Run the installation script. It will upload the function and its dependencies to AWS Lambda, as well as create the necessary roles, policies and triggers.

Additional Notes

Creating an Edgecast API key: https://support.globaldots.com/hc/en-us/articles/115004003749-Edgecast-Allowing-API-access

Adding authentication to Fastly purge: https://docs.fastly.com/guides/purging/authenticating-api-purge-requests

Good luck!

Latest Articles

An expert’s analysis: Here’s what we need to build a better IoT

Eduardo Rocha, Senior Solutions Engineer at GlobalDots, contributed a guest post to BuiltIn, the online community for startups and tech companies.  In the article, he outlined his approach for creating an IoT infrastructure that is both durable and secure. Here are some of the main takeaways: How One AI-Driven Media Platform Cut EBS Costs for AWS ASGs by […]

Eduardo Rocha Senior Sales Engineer and Security Analyst
28th February, 2023
What is a Content Delivery Network? CDN Explained

With the increasing demand for speedy and efficient content delivery, advanced solutions like the Content Delivery Network (CDN) have emerged. But what does CDN actually mean? Essentially, it’s a network of strategically positioned servers aimed at enhancing the speed and dependability of delivering content to users in different locations. These servers store cached copies of […]

Francesco Altomare Technical Sales Lead for Southern Europe, GlobalDots
4th January, 2023
It’s time to unleash the power of the force!

There’s a galactic misconception that monitoring CDNs has no value and is too expensive to store and index. While that used to be true, it’s now the worst mistake an IT-jedi can make!  GlobalDots, a 20-year CDN expert, teamed with observability innovator Coralogix, to develop a next generation observability platform for monitoring Content Delivery Networks’ […]

Ganesh The Awesome Senior Pre & Post-Sales Engineer at GlobalDots
12th December, 2022

Unlock Your Cloud Potential

Schedule a call with our experts. Discover new technology and get recommendations to improve your performance.

    GlobalDots' industry expertise proactively addressed structural inefficiencies that would have otherwise hindered our success. Their laser focus is why I would recommend them as a partner to other companies

    Marco Kaiser
    Marco Kaiser

    CTO

    Legal Services

    GlobalDots has helped us to scale up our innovative capabilities, and in significantly improving our service provided to our clients

    Antonio Ostuni
    Antonio Ostuni

    CIO

    IT Services

    It's common for 3rd parties to work with a limited number of vendors - GlobalDots and its multi-vendor approach is different. Thanks to GlobalDots vendors umbrella, the hybrid-cloud migration was exceedingly smooth

    Motti Shpirer
    Motti Shpirer

    VP of Infrastructure & Technology

    Advertising Services