Skip to content

wafv2: support native WAF request monetization (Monetize action + MonetizationConfig) #48418

Description

@arditti

Description

AWS WAF now supports charging for a web request natively — a new per-rule
Monetize action (alongside the existing Allow / Block / Count /
Captcha / Challenge) together with a WebACL-level monetization configuration.
This enables pay-per-request / AI-traffic monetization (x402-style HTTP 402
"Payment Required" challenges) directly at the edge, without Lambda@Edge.

The provider's wafv2 rule action block and aws_wafv2_web_acl schema do not
yet expose this. I'd like to add support.

Announcement: https://aws.amazon.com/blogs/aws/aws-waf-adds-ai-traffic-monetization-capability-to-help-content-owners-charge-ai-bots-for-content-access/ (2026-06-15 (GA))

I'm planning to implement this myself. The live wafv2 API already accepts a
Monetize rule action (verified via CheckCapacity); the remaining dependency
is the aws-sdk-go-v2/service/wafv2 release carrying the Monetize shape and
WebACL MonetizationConfig. If the SDK shape is available I'll open a complete
PR; otherwise I'll open it as a draft and finalize on the SDK bump.

Affected Resource(s) or Data Source(s)

  • aws_wafv2_web_acl
  • aws_wafv2_rule_group
  • aws_wafv2_web_acl (data source)
  • aws_wafv2_rule_group (data source)

Potential Terraform Configuration

resource "aws_wafv2_web_acl" "example" {
  name  = "monetize-example"
  scope = "CLOUDFRONT"

  default_action {
    allow {}
  }

  # New: WebACL-level monetization configuration
  monetization_config {
    crypto_config {
      payment_network {
        chain          = "BASE"
        wallet_address = "0x0000000000000000000000000000000000000000"

        prices {
          amount   = "0.001"
          currency = "USDC"
        }
      }
    }

    currency_mode = "REAL" # or "TEST"
  }

  rule {
    name     = "monetize-api"
    priority = 10

    statement {
      byte_match_statement {
        search_string         = "/api"
        positional_constraint = "STARTS_WITH"
        field_to_match {
          uri_path {}
        }
        text_transformation {
          priority = 0
          type     = "NONE"
        }
      }
    }

    # New: per-rule Monetize action
    action {
      monetize {
        price_multiplier = "5"
      }
    }

    visibility_config {
      cloudwatch_metrics_enabled = true
      metric_name                = "monetize-api"
      sampled_requests_enabled   = true
    }
  }

  visibility_config {
    cloudwatch_metrics_enabled = true
    metric_name                = "monetize-example"
    sampled_requests_enabled   = true
  }
}

References

Would you like to implement the enhancement?

Yes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequests to existing resources that expand the functionality or scope.service/wafv2Issues and PRs that pertain to the wafv2 service.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions