Files
acdl/modules/l1/waf/README.md
T
Jon Chery 031887ec56 refactor(P57): contract surface redesign + rename + .yml repo-wide
Contract surface redesign:
- New top-level fields: id (3-6 char acronym → stack.name), name (full → stack.title),
  infrastructure (map keyed by module name, replaces module:)
- Drop uses: field (dead reference; version pin lives in CI workflow uses: line)
- Drop top-level module/inputs (now nested under infrastructure map)
- Per-module optional version (defaults to latest published from registry)
- Multi-module contracts: one file deploys N modules in one pipeline run,
  resource IDs namespaced with module name to avoid collisions
- stack.schema.json: add optional title field for display name

Rename:
- pipelines/deploy.yaml → pipelines/contract.yml (declarative spec, not a pipeline)
- pipelines/ci.yaml → pipelines/ci.yml
- All 44 .yaml files → .yml repo-wide (contracts, module examples, kyverno policies)
- .acdl/contract.yaml → .acdl/contract.yml

Resolver (core/contract_resolver.py):
- Rewrite resolve() to loop infrastructure map, default version to latest,
  merge module fragments into one stack with namespaced resource IDs
- _latest_version() picks highest non-deprecated from registry
- _namespace_resources() prefixes IDs + rewrites ref: expressions for multi-module
- Single-module path: unprefixed IDs (backward compatible)

Verification:
- 494 tests pass (0 contract-shape failures)
- Local E2E passes (contract → resolver → adapter → local ECS HTTP 200 → outbox)

---ci---
project: acdl
phase: 57
milestone: v1.10.2
status: execute
---/ci---
2026-07-27 21:37:40 +00:00

108 lines
3.0 KiB
Markdown

# waf — WAFv2 Web ACL
> **Module kind:** primitive | **Version:** 1.0.0
A WAFv2 Web ACL scoped to CloudFront. It applies managed rule groups by
default and can be associated with a CloudFront distribution to filter
traffic before it reaches the origin. CloudFront-scoped Web ACLs are
always created in `us-east-1`.
## Resources
| Resource | Type | Purpose |
|----------|------|---------|
| `webacl` | `aws_wafv2_web_acl` | WAFv2 Web ACL with managed rules |
## Inputs
| Name | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `name` | string | yes | — | Name of the Web ACL |
| `scope` | string | no | `cloudfront` | Scope of the Web ACL (default cloudfront for CloudFront associations) |
| `default_action` | string | no | `allow` | Default action (default allow) |
| `rules` | string | no | — | Optional custom rules as JSON (default: managed rules only) |
| `region` | string | yes | — | AWS region (CloudFront-scoped WAF is always us-east-1; the adapter ignores this for cloudfront scope) |
## Outputs
| Name | Type | Description |
|------|------|-------------|
| `web_acl_arn` | arn | The WAF Web ACL ARN |
## Usage
```json
{
"id": "waf",
"type": "aws:wafv2:webacl",
"module": "waf@1.0.0",
"inputs": {
"name": "acdl-static-assets-waf",
"scope": "cloudfront",
"default_action": "allow",
"region": "us-east-1"
}
}
```
The `web_acl_arn` output is typically wired as a `ref:` expression into
the `cloudfront` primitive's `waf_web_acl_arn` input inside a module
composition (see `modules/l2/static-assets`).
## Compliance extension points
- **Rate limiting** — add a rate-based rule to cap requests per IP
(SOC2 CC6.1, DORA operational resilience).
- **Geo blocking** — add a geo-match statement to block/allow countries
for data-residency compliance (GDPR Art.44, SOC2 CC6.1).
- **Custom rules** — add custom rule statements for application-specific
filtering (e.g. block SQLi/IP allow-lists) (SOC2 CC6.1).
- **Logging** — enable WAF access logging to S3/CloudWatch/Kinesis for
auditability (SOC2 CC7.2, DORA audit trail).
## Examples
Validated example contracts are in [`examples/`](examples/). The platform-test
pipeline validates them against `schemas/contract.schema.json`.
### Simple
A minimal deployment:
[`examples/simple.yml`](examples/simple.yml)
```yaml
environment: dev
id: waf
infrastructure:
waf:
inputs:
name: my-waf
region: us-east-1
version: 1.0.0
name: waf-firewall
```
### Complex
A production deployment with optional inputs:
[`examples/complex.yml`](examples/complex.yml)
```yaml
environment: dev
id: waf
infrastructure:
waf:
inputs:
default_action: allow
name: my-production-waf
region: us-east-1
scope: cloudfront
version: 1.0.0
name: waf-firewall
```
## Versioning
`1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps
require a new registry entry (immutable publication); old entries enter
a 12-month deprecation window.