Most teams that try to automate firewall rules start by writing a script against the vendor API. Most of those scripts are dead within a year. The API was never the hard part. The hard part is that a firewall rule is a compressed, order-dependent encoding of an organizational decision — who may talk to whom, on which port, until when — and most organizations have never written that decision down anywhere a machine can read it.
Automate the intent, not the rule syntax
If your automation takes add a rule permitting 10.4.2.0/24 to 10.9.0.0/16 on 8443 as its input, you have automated typing, not policy. The unit of automation should be a service dependency: the checkout service calls the payments ledger on TCP 8443, owned by team-payments, reviewed quarterly. That is three lines of YAML. A compiler that understands topology turns it into eleven rules across four enforcement points — two cloud security groups, one Kubernetes NetworkPolicy, one zone pair on the perimeter firewall — plus the owner tag and the review date.
The difference matters because intent is queryable and rule syntax is not. When the payments ledger moves to a new subnet, the intent document doesn't change. When someone asks why a /16 is reachable from a /24, you have an answer that isn't a shrug.
The rulebase you have is not the rulebase you think you have
Before you build a pipeline, measure. Turn on per-rule hit counters, wait 90 days, sort descending, and count how many rules sit at zero. On a rulebase hand-maintained for five years — a few thousand rules, several admins, two acquisitions — it is common for a third of them to have never matched a packet. Another slice is shadowed: a rule above matches first, so it can never fire. A smaller set is genuinely dangerous: the 2022 temporary rule permitting any-to-any on a database port, still sitting there.
Rank by risk, not by count. A zero-hit rule that permits any-to-any on 3389 outranks a zero-hit rule for a decommissioned print server. This inventory is not a side quest — a compiler pointed at a messy rulebase will faithfully reproduce the mess at machine speed.
You cannot automate a rulebase you cannot explain; the first output of firewall automation is an inventory, not a pipeline.
A pipeline that works: five stages
The stages are boring, and the boring parts are where the value lives.
- Declare. Intent lives in git, one file per service dependency, with an owner, a port list, a protocol, and a review date. Nothing without an owner merges.
- Validate. CI rejects
0.0.0.0/0sources, ports outside an approved registry, unnamed peers, and dependencies with no review date. Policy-as-code runs on every pull request. - Compile. A deterministic compiler emits vendor configuration for each enforcement point. Determinism matters: identical intent must produce a byte-identical diff, or review becomes impossible.
- Simulate. Replay real flow data against the proposed ruleset and publish the delta — what becomes newly permitted, what would now be blocked.
- Apply and reconcile. Push via API, then run a nightly job that compares running configuration to git and opens a ticket on drift.
The payoff is latency, not elegance. A manually routed firewall request — ticket, security review, change window, engineer — typically lands somewhere between three and five days. A merged pull request that compiles, simulates, and applies lands in under ten minutes, and the change window disappears because the change set is small, reviewed, and reversible.
Flow logs are the only honest requirements document
Nobody remembers what actually talks to what. Ask five engineers which services need to reach the payments database and you get five lists, all incomplete. Seven days of flow logs are more truthful than all five.
The workflow: pull flow records, resolve each endpoint to a workload identity (cloud tags, Kubernetes labels, CMDB, or reverse DNS where identity is missing), aggregate into service pairs, and diff that graph against declared intent. What you get is a migration plan. Flows present in both are safe to move first — often 80–90% of traffic in a mature estate. Flows in logs but not intent are either undocumented dependencies or traffic worth killing. Flows in intent but not logs are rules you can retire. Where identity is genuinely unavailable — legacy appliances, mainframes — fall back to /24 grouping and mark those as exceptions with an owner and a review date.
The simulation report is what makes this politically survivable. A pre-flight result reading 42 flows newly permitted, 0 previously permitted flows blocked gets approved. A change request that says trust us, it is declarative now, does not.
Guardrails: what to automate, and what to keep human
Full automation of every firewall change is a mistake. Automate the routine 90% and keep a narrow, audited manual path for the rest.
- Cap the blast radius: no more than 25 rules per change, and a hard limit on how many enforcement points a single merge can touch.
- Canary by scope: apply to 5% of affected workloads first, hold for 30 minutes, and watch deny counters before proceeding.
- Roll back automatically on a deny spike, not when a human notices a broken service at 2 a.m.
- Give break-glass a clock: it must open a ticket, and everything it creates expires in 24 hours unless converted to intent.
- Keep a human signature on changes that widen trust — removing a deny, adding internet-facing ingress, opening a database port to a new zone.
Every one of those limits should be a number in code, not a norm in a wiki. Norms decay.
Where this is heading
The firewall console is becoming a compile target. Intent graphs, identity-based enforcement, and workload-scoped rules that expire when the workload does are already replacing the long-lived zone-pair model in cloud-native estates; the perimeter rulebase is increasingly a generated artifact with a short lifetime and a review date attached.
That changes what a firewall team is for. The valuable work is modeling dependencies, arbitrating trust, and reviewing the small number of changes that genuinely widen access. Everything else — syntax, ordering, vendor dialects — is compilation. Teams that get this right stop measuring rules managed per engineer. They measure how many rules they deleted, and how fast the survivors ship.

