cel-engine
Validates CloudFormation templates using a three-tier evaluation strategy: native Rust rule functions for built-in rules, a generated rule registry for data-driven rules, and the cel-interpreter for user-provided custom rules. Implements the ValidationEngine trait.
Architecture
CelEngine::evaluate_rules(model, config)
│
├── Tier 1: Native Rust functions (built-in rules, max performance)
├── Tier 2: Generated rule descriptors (data-driven rules from schemas)
└── Tier 3: Custom CEL expressions (user-provided + translated Guard rules)
│
▼
Vec<Diagnostic>
- Tier 1 - Native Rust functions organized by category (Structure, Intrinsic, Reference, BestPractice,
Resource, Security). Access the
SemanticModeldirectly with no serialization overhead. - Tier 2 - JSON rule descriptors generated by data-source, evaluated natively against
the
SemanticModel. Indexed by resource type for efficient lookup. - Tier 3 - User-provided CEL expressions and translated Guard rules, compiled at engine init and evaluated via the CEL interpreter at runtime.
Custom CEL Rules
Custom rules are provided as JSON:
For resource-scoped rules (resource_type set), the engine iterates over all resources of that type and evaluates the
CEL expression with resource-specific context. For global rules (no resource_type), the expression is evaluated once.
Guard rules are translated to this format automatically at engine initialization.
CEL Context Variables
| Variable | Type | Scope | Content |
|---|---|---|---|
resources |
map | Global | All resolved resources keyed by logical ID |
parameters |
map | Global | All parameters with metadata |
conditions |
map | Global | All conditions |
outputs |
map | Global | All outputs |
mappings |
map | Global | All mappings |
template |
map | Global | Template metadata (transforms, format version, description) |
name |
string | Per-resource | Current resource's logical ID |
resource |
map | Per-resource | Current resource's full resolved data |
properties |
map | Per-resource | Current resource's resolved properties |
resolved_properties |
map | Per-resource | Properties with intrinsic functions fully resolved to values |