Url icon
Keys icon
SlackIncomingWebhook icon
Webhook icon

Purge Fastly Cache on Deploy via Webhook

Purge the Fastly edge cache automatically when a deploy goes live with Kestra. Soft-purge the page URL and surrogate keys, then confirm to Slack.

Categories
CloudInfrastructure

A deployment is not done when the pipeline turns green, it is done when the edge serves the new version. Fastly caches aggressively by design, so a release that ships without an invalidation step keeps serving the previous HTML and assets until TTLs expire. This blueprint closes that gap: the CD pipeline calls a Kestra webhook the moment a release is live, and the flow soft-purges both the deployed page URL through io.kestra.plugin.fastly.purge.Url and the surrogate keys the release touched through io.kestra.plugin.fastly.purge.Keys, then posts the purge IDs to Slack. Soft purge marks objects stale instead of deleting them, so the edge revalidates against origin rather than stampeding it, which makes it the safer default for deploy-time invalidation.

How it works

  1. on_deploy (io.kestra.plugin.core.trigger.Webhook) listens for an HTTP call from the CD system. Replace the placeholder key with a strong random value before deploying, since it guards the endpoint.
  2. purge_page (io.kestra.plugin.fastly.purge.Url) purges the URL from the webhook body, falling back to the page_url input when the body carries none, with soft: true. Its status and id outputs feed the confirmation message.
  3. purge_surrogates (io.kestra.plugin.fastly.purge.Keys) splits the comma-separated surrogate_keys input and purges all keys in one batch call against service_id. Its purgeIds output maps each key to its purge ID.
  4. notify posts the purged URL, purge status and ID, and the number of surrogate keys invalidated to Slack.
  5. The errors block posts a distinct Slack alert when any purge call fails, because a stale edge after a deploy fails silently otherwise.

What you get

  • Zero-stale releases: the edge revalidates the new version as soon as the pipeline reports success.
  • Soft purge by default, so origin sees revalidation traffic instead of a full cache-miss stampede.
  • Purge IDs in Slack for every release, giving cache invalidation the same audit trail as the deploy itself.
  • A webhook any CD system can call, from GitHub Actions to Argo CD to a plain curl in a deploy script.

Who it's for

  • Platform and DevOps engineers wiring CDN invalidation into delivery pipelines.
  • Frontend teams shipping behind Fastly who keep fielding "I still see the old version" reports after releases.
  • SRE teams who want deploy-time purges observable and replayable instead of buried in a deploy script.

Why orchestrate this with Kestra

Fastly has no concept of a deployment, its cache clears on TTL or an API call someone remembers to make. Kestra turns the purge into an event-driven, observable step: the webhook trigger connects any CD system, retries cover transient API failures, outputs from the purge tasks flow straight into the Slack confirmation, and every invalidation is recorded in the execution history next to the release that caused it.

Prerequisites

  • A Fastly service and an API token with purge permission.
  • A CD system able to POST to the Kestra webhook URL when a release goes live.
  • Content tagged with surrogate keys via the Surrogate-Key response header, so key-based purges have something to match.

Secrets

  • FASTLY_API_TOKEN: Fastly API token with purge scope.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL.

Quick start

  1. Add the two secrets to your Kestra namespace and replace the webhook key with a strong random value.
  2. Set service_id, page_url, and surrogate_keys to match your Fastly service.
  3. Point your CD post-deploy hook at the webhook URL, optionally passing a url field in the JSON body.
  4. Ship a release and check Slack for the purge confirmation.

How to extend

  • Pass the list of changed pages in the webhook body and loop purge.Url over them with io.kestra.plugin.core.flow.ForEach.
  • Add a post-purge probe with io.kestra.plugin.core.http.Request to confirm the page serves the new build.
  • Switch soft: false for content that must disappear immediately, such as takedowns.
  • Chain a cache warm-up that requests the purged URLs so the first real visitor gets a hit.

Links

Orchestrate with Kestra
Orchestrate Slack with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.