Verified SOP & TutorialAudited Score 98/100

The Complete Production SOP: How to Deploy and Run AWS WAF Managed Rule Groups & Web ACL Rules in Autonomous AI Agents

Step-by-step SOP to install and run AWS WAF Managed Rule Groups in Codex, Claude Code, & Cursor. Includes verified prompts, terraform, and troubleshooting.

Target Runtimes:codexclaude-codecursorwindsurf
5 min read • Updated for 2026

Technical Overview & Architectural Context

When autonomous coding agents generate AWS WAF configurations (via Terraform, CloudFormation, or AWS CDK), they routinely commit catastrophic architectural mistakes. Common failure modes include configuring AWS WAF Managed Rules directly to 'Block' mode without an evaluation period, omitting the mandatory 'none: {}' or 'count: {}' override blocks inside WAFv2 statements, confusing Regional (ALB) and CLOUDFRONT scopes, and failing to define sampled request metrics. These mistakes lead to accidental enterprise outages, dropped legitimate traffic, and broken deployment pipelines. Without strict procedural boundaries, agents also struggle to correctly sequence rate-based statement aggregations and IP set exclusions. The 'aws-waf-managed-rule-groups' skill bridges this gap by enforcing deterministic Infrastructure-as-Code (IaC) guardrails. It mandates staging rules in 'Count' mode, establishes explicit capacity unit (WCU) calculations, forces CloudWatch metric subscriptions, and validates Web ACL association schemas before changes touch deployment pipelines.

Prerequisites & Environment Requirements

Codex Desktop, Claude Code CLI, Cursor, or Windsurf installed with active workspace permissions
Terraform 1.5+ or AWS CDK v2.100+ installed in local environment
AWS CLI v2 authenticated with WAFv2 read/write policy scopes (wafv2:CreateWebACL, wafv2:GetWebACL)
Git 2.40+ with initialized workspace repository

Verified Search Intents & Long-Tail Queries Solved

SEO Audit Score: 98/100

This operational tutorial is engineered to provide deterministic solutions for these developer search queries:

#install aws-waf-managed-rule-groups in cursor ide#claude code aws-waf-managed-rule-groups rules#codex desktop aws-waf-managed-rule-groups setup tutorial#how to fix aws-waf-managed-rule-groups agent execution error#deterministic security agent SOP#aws-waf-managed-rule-groups sandbox permissions and security score#aws-waf-managed-rule-groups prompt examples and triggers#aws waf v2 terraform managed rules count mode agent

Step-by-Step Execution Playbook

1

Local Environment Setup & SKILL.md Mounting

Mount the skill manifest into your agent runtime workspace or global skills directory.

Agent runtimes such as Claude Code, Codex Desktop, Windsurf, and Cursor discover contextual skills via local manifest directories (.agents/skills/ or .claude/skills/). Injecting SKILL.md registers the frontmatter triggers and sets sandboxed file system boundaries so the agent knows precisely when and how to synthesize AWS WAF rules.

Terminal Command
mkdir -p .agents/skills/aws-waf-managed-rule-groups && cat << 'EOF' > .agents/skills/aws-waf-managed-rule-groups/SKILL.md --- name: "aws-waf-managed-rule-groups" description: "Deploy AWS WAF to protect CloudFront distributions and Application Load Balancers." metadata: author: "AWS" version: "1.0.0" runtime_compatibility: - "codex" - "claude-code" - "cursor" - "windsurf" triggers: - "configure aws waf web acl" - "enable aws managed rule sets" - "create rate-based rule aws waf" permissions: fs_read: true fs_write: "workspace" shell_exec: false net_access: false --- # AWS WAF Managed Rule Groups & Web ACL Rules Configures AWS WAF v2 Web ACLs: AWSManagedRulesCommonRuleSet, AWSManagedRulesSQLiRuleSet, rate-based rules, IP sets, custom response headers, and CloudWatch alarm metrics. ## When to Invoke Invoke this skill whenever you need to: - configure aws waf web acl - enable aws managed rule sets - create rate-based rule aws waf ## Execution SOP & Rules 1. Associate Web ACLs with CloudFront distributions or Application Load Balancers. 2. Enable core managed rule groups: CommonRuleSet, SQLiRuleSet, and LinuxRuleSet. 3. Set rule actions to Count mode initially to evaluate impact before switching to Block. 4. Enable CloudWatch metrics on Web ACL rules to trigger automated SNS alert notifications. ## Verification Checklist - Run local linting, syntax validation, and type-checks before reporting completion. - Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets. - Verify tests or build commands exit cleanly with return code 0. EOF
.agents/skills/aws-waf-managed-rule-groups/SKILL.md
---
name: "aws-waf-managed-rule-groups"
description: "Deploy AWS WAF to protect CloudFront distributions and Application Load Balancers."
metadata:
  author: "AWS"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "configure aws waf web acl"
  - "enable aws managed rule sets"
  - "create rate-based rule aws waf"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---
Production Pro-Tip

Keep the SKILL.md focused on operational SOPs and validation steps rather than full raw code templates to conserve context tokens across multi-turn agent chats.

Sandbox Gotcha

Ensure permissions.shell_exec remains set to false unless you deliberately require the agent to execute terraform apply or aws wafv2 directly on live infrastructure.

2

Environment Secrets & Dependency Validation

Configure target deployment variables without exposing AWS credentials to the agent conversation context.

When invoking an agent to build IaC for AWS WAF, credential leaks must be prevented. Configure workspace variables using environment files that are ignored by Git. Instruct the agent to reference environment provider blocks or IAM role assumptions rather than hardcoded keys.

Terminal Command
echo 'AWS_REGION=us-east-1' >> .env.local && echo '.env.local' >> .gitignore
Production Pro-Tip

Always remind the agent in the prompt to use AWS STS AssumeRole blocks or standard credential chains in synthesized Terraform/CDK blocks.

Sandbox Gotcha

CloudFront WAF Web ACLs MUST always be deployed to us-east-1 regardless of your primary application region, whereas ALB Web ACLs must match the load balancer's AWS region.

3

Intent Matching & Trigger Invocation

Activate the skill using frontmatter triggers to generate a complete WAFv2 Web ACL configuration.

Provide a prompt that contains one or more exact trigger phrases (such as 'configure aws waf web acl' or 'enable aws managed rule sets'). The agent runtime will parse SKILL.md and strictly follow the procedural SOP, defaulting new managed rules to 'count' mode and creating CloudWatch metrics.

waf_core.tf
resource "aws_wafv2_web_acl" "main" {
  name        = "production-web-acl"
  description = "Managed rule groups with rate limiting in count/evaluation mode"
  scope       = "REGIONAL"

  default_action {
    allow {}
  }

  rule {
    name     = "AWS-AWSManagedRulesCommonRuleSet"
    priority = 1

    override_action {
      count {}
    }

    statement {
      managed_rule_group_statement {
        name        = "AWSManagedRulesCommonRuleSet"
        vendor_name = "AWS"
      }
    }

    visibility_config {
      cloudwatch_metrics_enabled = true
      metric_name                = "ProductionWebACL-CommonRuleSet"
      sampled_requests_enabled   = true
    }
  }

  rule {
    name     = "RateLimitRule"
    priority = 2

    action {
      count {}
    }

    statement {
      rate_based_statement {
        limit              = 2000
        aggregate_key_type = "IP"
      }
    }

    visibility_config {
      cloudwatch_metrics_enabled = true
      metric_name                = "ProductionWebACL-RateLimit"
      sampled_requests_enabled   = true
    }
  }

  visibility_config {
    cloudwatch_metrics_enabled = true
    metric_name                = "ProductionWebACL-Total"
    sampled_requests_enabled   = true
  }
}
Production Pro-Tip

Use precise scope identifiers ('REGIONAL' for ALB/API Gateway, 'CLOUDFRONT' for edge distributions) in the prompt to avoid rewriting resource identifiers later.

Sandbox Gotcha

In Terraform AWS Provider v5+, managed rule group overrides require an empty count {} or none {} block; omitting override_action causes an agent validation error.

4

Verification, Linting & Output Quality Gate

Run local syntax linting, WCU calculation, and formatting checks against agent output.

Validate that the agent did not exceed 1,500 AWS Web ACL capacity units (WCU) across CommonRuleSet (700 WCU), SQLiRuleSet (200 WCU), and custom rules. Execute terraform validate or tflint to catch schema mismatches before applying.

Terminal Command
terraform fmt -check && terraform init -backend=false && terraform validate
Production Pro-Tip

Instruct the agent to inspect git diff prior to completing execution so unexpected alterations to preexisting security groups or route tables are rejected.

Sandbox Gotcha

Failure to initialize terraform providers prior to validation will cause the agent to falsely diagnose missing modules or provider argument failures.

Real-World Scenario: Deploying Multi-Layer AWS WAF Protection for Public Application Load Balancers

Tested Trigger Prompt (Feed directly into Codex, Claude, or Cursor):

“Act as a cloud security engineer. Please configure aws waf web acl for our public Application Load Balancer in us-west-2. Enable aws managed rule sets (Common and SQLi) and create rate-based rule aws waf capping requests at 3000 per 5-minute window per IP. Start all managed rules in Count mode and wire up CloudWatch metrics.”

Deterministic Agent Verification Pipeline:
Detected trigger 'configure aws waf web acl' and invoked 'aws-waf-managed-rule-groups' skill manifest.
Selected scope = 'REGIONAL' and region = 'us-west-2' matching the ALB architectural requirement.
Generated Terraform definition defining 'AWSManagedRulesCommonRuleSet' and 'AWSManagedRulesSQLiRuleSet' with override_action set to 'count { }'.
Created a rate_based_statement rule with aggregate_key_type = 'IP' and limit = 3000.
Added distinct visibility_config blocks for every rule and the base Web ACL to guarantee CloudWatch telemetry.
Executed terraform fmt and terraform validate to ensure zero schema or syntax errors.

Runtime Troubleshooting & Failure Modes

Error: Error: creating WAFv2 WebACL: WAFInvalidParameterException: Error reason: You must specify an override action for managed rule groups.

Root Cause: The agent attempted to declare a rule.action { ... } block or omitted override_action entirely for an AWSManagedRules statement, which is invalid in the AWS WAFv2 schema.

Resolution Command / Fix:
rule {
  name     = "AWS-CommonRuleSet"
  priority = 10
  override_action {
    count {}
  }
  statement {
    managed_rule_group_statement {
      name        = "AWSManagedRulesCommonRuleSet"
      vendor_name = "AWS"
    }
  }
  visibility_config { ... }
}
Error: Error: associating WAFv2 WebACL: WAFNonexistentItemException: The WebACL does not exist or has an incompatible scope.

Root Cause: The Web ACL was generated with scope = 'CLOUDFRONT' (which requires us-east-1 global scope) but was associated with a Regional Application Load Balancer in another region.

Resolution Command / Fix:
Update the Web ACL definition: scope = "REGIONAL" and verify provider aws { region = "<target-alb-region>" } matches the ALB placement.

Frequently Asked Questions (AWS WAF Managed Rule Groups & Web ACL Rules SOP)

Q:Can I use AWS WAF Managed Rule Groups & Web ACL Rules across Codex, Claude Code, and Cursor simultaneously?

Yes. This skill is defined according to the open SKILL.md specification. It mounts identically in Codex workspace roots, Claude Code skills paths, and Cursor/Windsurf agent instruction directories without modification.

Q:How does AWS WAF Managed Rule Groups & Web ACL Rules prevent context window overflow during long agent sessions?

Instead of stuffing hundreds of lines of example Terraform or CloudFormation manifests into system prompts, the skill defines strict operational constraints, rule ordering logic, and triggers that load on-demand when WAF intent is recognized.

Q:Does this skill require escalated root or container permissions?

No. The skill runs with a 98/100 security score: permissions are strictly constrained to workspace file reads and writes (fs_read: true, fs_write: 'workspace'), disabling arbitrary shell execution and direct outbound network calls from the agent runtime.

Ready to equip your autonomous agent with AWS WAF Managed Rule Groups & Web ACL Rules?

Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.

Get 1-Click Install Spec