Loop icon
Download icon
Get icon
Script icon
If icon
SlackIncomingWebhook icon
Set icon
Schedule icon

Get the Exact CIDRs to Change When a Vendor Updates Its IP Ranges

Diff the IP ranges published by GitHub, Cloudflare, Stripe, AWS and other vendors and post the CIDRs to add or remove from your firewall allowlists.

Categories
CloudInfrastructure

Firewalls, security groups and WAF rules often allowlist a vendor's IP ranges: GitHub webhooks reaching a self-hosted CI, Stripe webhooks reaching the payment API, Cloudflare in front of an origin, CloudFront talking to a private load balancer. Vendors publish those ranges as JSON and change them a few times a year. When nobody notices, webhooks start failing from the new addresses, or retired addresses stay open long after someone else owns them.

This blueprint downloads each vendor's published document, extracts the ranges with a jq expression, and compares them with the last run. When something changed, Slack gets the exact CIDRs to add and remove, and the execution has an up-to-date allowlist file per vendor that a Terraform, Ansible or firewall flow can use.

A sudden drop of more than max_removed_percent of the ranges looks more like a broken or truncated document than a real change. It is posted as held and the stored list is kept; if the next run returns the same list, the change is accepted and posted again as confirmed.

How it works

For each entry in sources (Loop, four at a time):

  1. fetch_ranges downloads the vendor's document.
  2. load_previous reads the list recorded at the last run from the Kestra KV store.
  3. compare applies the jq expression, normalizes every entry to a CIDR (a bare IP becomes a /32 or /128), diffs the lists, and writes <name>.txt.
  4. if_changed skips Slack when nothing changed. The first run only records the lists.
  5. alert_owner posts the additions and removals, or the held-change warning.
  6. remember_ranges stores the new list, after the alert.

Prerequisites

  • A Slack Incoming Webhook. The default documents are public and need no key.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for alerts and failures.

In the open-source edition, secrets are environment variables on the Kestra container, prefixed with SECRET_ and base64-encoded. See how to manage secrets.

Inputs

  • sources (JSON): list of {"name", "url", "jq", "owner"} objects. More sources that work the same way:
    • Google Cloud: https://www.gstatic.com/ipranges/cloud.json with [.prefixes[] | (.ipv4Prefix // .ipv6Prefix)]
    • Fastly: https://api.fastly.com/public-ip-list with .addresses + .ipv6_addresses
    • GitHub Actions runners: https://api.github.com/meta with .actions (several thousand ranges)
    • Any AWS service and region: [.prefixes[] | select(.service == "EC2" and .region == "eu-west-1") | .ip_prefix]
  • max_removed_percent (INT, default 50): the removal safety limit.

Quick start

  1. Add the Slack secret, and keep only the vendors you actually allowlist.
  2. Execute the flow once to record the current lists.
  3. Enable every_six_hours. When Slack posts a change, apply it, or let a follow-up flow read the <name>.txt output and apply it for you.

Outputs

  • {{ outputs.compare.outputFiles['<name>.txt'] }} per iteration: the current allowlist, one CIDR per line.
  • {{ outputs.compare.vars }} per iteration: count, added, removed, held, confirmed.
  • KV entries ip_ranges_<name>: the list recorded at the last run, and a held list if any.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.