Schedule icon
AwsCLI icon
If icon
SlackIncomingWebhook icon
Log icon

WAFv2 Web ACL Capacity Quota Sentinel

Monitor AWS WAFv2 web ACL capacity (WCUs) and alert Slack before the cost tier or fixed quota is exceeded.

Categories
Infrastructure

Every AWS WAFv2 web ACL has a fixed, non-adjustable 5,000 Web ACL Capacity Unit (WCU) ceiling, and a lower 1,500 WCU base-price ceiling beyond which AWS bills extra per WCU. Neither limit shows up anywhere until a CreateWebACL or UpdateWebACL call to add one more rule fails outright, often discovered for the first time while a team is actively trying to add a rule to block an ongoing attack. This blueprint reads the web ACL's current consumed capacity on a schedule and alerts Slack well before either threshold is crossed.

How it works

  1. periodic_capacity_check (io.kestra.plugin.core.trigger.Schedule) runs every 30 minutes, explicitly passing aws_region, web_acl_name, web_acl_id, scope, cost_tier_threshold, and critical_threshold through its own inputs: block so the flow is self-contained when the trigger fires. Shipped disabled so a manual run can be verified first.
  2. probe_web_acl_capacity (io.kestra.plugin.aws.cli.AwsCLI) runs aws wafv2 get-web-acl --query 'WebACL.Capacity' --output text, extracting just the consumed-WCU scalar rather than the full web ACL JSON, guarding against an empty or non-numeric result, and emitting it as the named output capacity.
  3. evaluate_capacity_tier (io.kestra.plugin.core.flow.If) branches into three states via nesting:
    • CAPACITY_CRITICAL: Capacity at or above critical_threshold (default 4,500, 90% of the fixed 5,000 WCU hard cap) - alert_capacity_critical fires.
    • COST_TIER_EXCEEDED: Capacity at or above cost_tier_threshold (default 1,500, AWS's own base-price ceiling) but below critical - alert_cost_tier_exceeded fires.
    • HEALTHY: below both thresholds - log_capacity_healthy records the pass.
  4. log_audit_complete always runs last, printing the final Capacity regardless of which branch fired.
  5. The errors block alerts Slack separately if the flow itself fails outright - a web ACL name/id/scope combination that does not exist, or invalid credentials.

What you get

  • A capacity answer computed from AWS's own Capacity field, not from counting rules or summing estimated WCU costs client-side.
  • Two distinctly different alert tiers mapped to AWS's own two real thresholds - a cost signal at 1,500 WCUs and a hard-cap-approaching operational risk signal at 4,500 WCUs - instead of one generic "capacity is high" warning.
  • A Resource Quota Enforcement sentinel for a quota that AWS itself gives zero proactive warning about: the only native signal today is a failed API call when someone tries to add one rule too many.
  • A worked example of io.kestra.plugin.aws.cli.AwsCLI on wafv2 get-web-acl, with no prior blueprint coverage of this plugin surface in this repository.

Who it's for

  • Security and platform engineering teams who own one or more WAFv2 web ACLs and want to know they are approaching the fixed WCU cap before a rule deploy fails during an incident.
  • FinOps-minded teams who want a heads-up the moment a web ACL crosses into AWS's extra-cost WCU tier, rather than noticing it on the next bill.
  • Anyone evaluating the AWS plugin who wants a worked example of AwsCLI reading a quota/capacity value that has no dedicated Kestra task and no CloudWatch metric equivalent.

Why orchestrate this with Kestra

AWS WAF has no built-in "alert me before I hit my WCU cap" primitive - CloudWatch WAF metrics track request counts and rule matches, not capacity consumption, and the only native signal is the error returned by the next UpdateWebACL call. Kestra supplies the schedule, the HEALTHY/COST_TIER_EXCEEDED/CAPACITY_CRITICAL classification as a first-class three-way branch, and an execution history showing exactly when capacity crossed each threshold.

Prerequisites

  • A real AWS WAFv2 web ACL (update web_acl_name, web_acl_id, scope, aws_region).
  • AWS credentials with wafv2:GetWebACL permission - entirely read-only, cannot modify any rule or association.
  • A Slack incoming webhook for alerts.

Secrets

  • AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY: credentials for io.kestra.plugin.aws.cli.AwsCLI.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used by both alert branches and the errors block.
  • In Kestra OSS (no Enterprise secrets backend), secrets are supplied as environment variables prefixed SECRET_, base64-encoded - for example SECRET_AWS_SECRET_ACCESS_KEY=$(echo -n '<your-secret-key>' | base64) - and read back in flows with {{ secret('NAME') }}.

Inputs

  • aws_region (STRING, default us-east-1): region for the AWS CLI call (REGIONAL scope); CLOUDFRONT scope always uses us-east-1.
  • web_acl_name / web_acl_id (STRING, required, no default - a placeholder cannot satisfy their validator regexes): identify the target web ACL; find the ID via aws wafv2 list-web-acls or the console.
  • scope (SELECT, default REGIONAL): REGIONAL or CLOUDFRONT.
  • cost_tier_threshold (INT, default 1500): AWS's own documented base-price WCU ceiling.
  • critical_threshold (INT, default 4500): 90% of AWS's fixed 5,000 WCU hard cap.

Outputs

  • outputs.probe_web_acl_capacity.vars.capacity (Integer): consumed WCUs, extracted via --query 'WebACL.Capacity' --output text from get-web-acl's own documented output schema. This is the only output field this task captures - the full WebACL object (Name, Id, ARN, Rules, etc.) is not fetched or stored.

Quick start

  1. Identify a real WAFv2 web ACL and note its name, ID, and scope (aws wafv2 list-web-acls --scope REGIONAL).
  2. Add the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and SLACK_WEBHOOK_URL secrets.
  3. Run the flow manually and confirm log_capacity_healthy fires if the ACL is comfortably under 1,500 WCUs.
  4. Temporarily lower cost_tier_threshold below the ACL's real Capacity and re-run to confirm alert_cost_tier_exceeded fires; lower critical_threshold the same way to confirm alert_capacity_critical fires.
  5. Enable periodic_capacity_check once you trust the check against your real web ACL.

How to extend

  • Loop over several web_acl_name/web_acl_id/scope combinations with io.kestra.plugin.core.flow.Loop to audit every web ACL in an account in one run.
  • Add a preceding aws wafv2 list-web-acls task to resolve web_acl_id automatically from web_acl_name, removing the need to look the ID up manually - kept out of this sentinel to avoid an extra layer of client-side string matching between two AWS CLI calls.
  • Add a remediation branch with a second AwsCLI task calling get-web-acl without the --query filter, to post the web ACL's full Rules list to Slack alongside the alert, so the team can immediately see which rule is the largest WCU consumer and a candidate for trimming.

Pitfalls

  • The 1,500 WCU threshold is a cost boundary, not a hard failure; the 5,000 WCU threshold is the real hard cap - verified directly from AWS's own WAF quotas documentation, which states the 5,000 WCU-per-web-ACL quota "can't be changed." Treat CAPACITY_CRITICAL as the urgent signal and COST_TIER_EXCEEDED as the lower-urgency one.
  • get-web-acl requires the exact web_acl_id, not just the name - two web ACLs with different IDs can share a display name across scopes or accounts, so this blueprint cannot resolve the ID for you; look it up with list-web-acls first.
  • CloudFront-scope web ACLs always live in us-east-1 regardless of the aws_region input - this blueprint switches the AWS CLI call to us-east-1 automatically when scope is CLOUDFRONT, because the CLI requires that region for CloudFront-scope web ACLs.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.