Security teams should define WAFv2 controls as code, import existing resources into Terraform, and standardise deployment patterns across CloudFront and regional services. That approach reduces ClickOps drift, improves repeatability, and makes policy changes reviewable through normal infrastructure workflows. Teams should also align CloudWatch metrics and sampled requests to validate whether protections are working as intended.
Why This Matters for Security Teams
AWS WAFv2 often looks straightforward until teams have to manage it across both CloudFront and regional services, where scope, provider aliases, and deployment order differ in ways that break naive Terraform patterns. Security teams are not just codifying rules; they are controlling enforcement points that can materially affect availability, false positives, and incident response. NHI Management Group’s research on the state of non-human identity security shows how quickly weak operational controls become attack paths when credentials or policy changes are not tightly governed.
That matters because WAF policy drift is rarely discovered through audits first. It is usually found when a release is blocked, a protection is bypassed, or a rule update behaves differently in one environment than another. Terraform can reduce that risk, but only when teams treat WAFv2 as an environment-specific control surface, not as a single global template. Current guidance from the NIST Cybersecurity Framework 2.0 supports repeatable control management, but the implementation details are where most teams struggle. In practice, many security teams encounter WAF drift only after a production change has already altered traffic behaviour.
How It Works in Practice
Security teams should split WAFv2 management into two patterns: global resources for CloudFront and regional resources for application stacks that live behind ALB, API Gateway, or AppSync. Terraform should model those differences explicitly, usually with separate modules, provider aliases, and variables for scope so that the same policy logic can be reused without pretending the control plane is identical. That separation also makes it easier to import existing Web ACLs, rule groups, and associations before enforcing desired state.
For operational control, use Terraform to manage the rule set, logging configuration, and associations together. That gives reviewers a single change record for policy logic and where it is attached. Where teams rely on managed rule groups, they should still define explicit priorities and override actions so that downstream changes are visible in code review. Validation should include CloudWatch metrics, sampled requests, and change windows, because a WAF rule that exists in Terraform is not the same thing as a WAF rule that is actually blocking the intended traffic. The NIST SP 800-53 Rev. 5 Security and Privacy Controls is useful here for framing configuration management, continuous monitoring, and least functionality.
Teams should also align their Terraform workflow with import and drift detection. Existing console-managed ACLs should be imported first, then normalised into module patterns, then locked behind review and pipeline enforcement. That approach fits the lifecycle discipline described in the NHI Lifecycle Management Guide, even though WAF is not itself an identity control, because the same governance principle applies: unmanaged changes create invisible risk. In practice, WAFv2 controls tend to break down when one team manages CloudFront scope through a different pipeline than regional scope, because rule naming, priority order, and association timing diverge quickly.
Common Variations and Edge Cases
Tighter WAF standardisation often increases pipeline complexity, requiring organisations to balance consistency against the operational overhead of managing multiple scopes and environments. That tradeoff becomes sharper in shared AWS organisations, where security teams want one baseline but application teams need region-specific exceptions for legacy paths, health checks, or partner IP allowlists. Current guidance suggests using a shared core module with small, approved overrides rather than duplicating entire ACLs per account.
Edge cases appear when a single policy must protect CloudFront globally and regional endpoints locally. CloudFront WAFv2 must be created in the correct global context, while regional ACLs are tied to a specific region and resource association. If the team does not separate those concerns, Terraform plans can look correct but fail at apply time or attach to the wrong scope. Another common issue is rule evaluation order: rate-based rules, managed rule groups, and custom exclusions can interact differently depending on whether a service is public, behind a CDN, or fronted by an API gateway.
The most reliable pattern is to document each exception in code, review the exception expiry, and verify the policy through sampled requests after deployment. For teams tracking broader NHI exposure and automated abuse paths, NHI Management Group’s Top 10 NHI Issues is a useful reminder that weak governance around machine-controlled systems usually shows up first as drift, not as a clean policy failure.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10, CSA MAESTRO and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | PR.AC-4 | WAF associations and scope changes affect access enforcement at the application edge. |
| NIST AI RMF | Supports governance, monitoring, and accountability for automated policy changes in cloud environments. | |
| OWASP Non-Human Identity Top 10 | NHI-01 | Terraform-managed WAF depends on secure machine-to-machine credentials and change control. |
| CSA MAESTRO | Provides governance patterns for cloud and agent-driven operational workflows that alter security controls. | |
| OWASP Agentic AI Top 10 | Relevant when automated pipelines or agents can modify WAF policies without strong runtime guardrails. |
Define ownership, monitoring, and change review for WAF policies as part of an explicit AI risk-style governance model.
Related resources from NHI Mgmt Group
- How should security teams govern secrets across AWS and non-AWS environments?
- How should security teams manage identity architecture across complex environments?
- How should security teams manage SSL certificate sprawl across large environments?
- How should security teams manage policy consistency across multi-cloud environments?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 28, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org