Company
Date Published
Author
Jasper Van der Jeugt, Becki Lee
Word count
2514
Language
English
Hacker News points
None

Summary

The Rego language is a declarative query language used to write policy as code, which applies programming practices like version control and modular design to evaluate cloud and infrastructure as code (IaC) resources. Rego rules are conditional assignments that query the input to find matches for conditions, assigning values to variables if a match is found. The AND and OR operators can be combined in rule heads to represent multiple conditions that must be met for a variable to be assigned. Default values and syntactic sugar simplify writing rules with default values. Custom messages can be returned by using the `deny[msg]` rule head, which assigns a message to the `msg` variable. The `not` keyword is used to negate expressions, checking for the absence of properties in the input. Rego evaluates rules against JSON or YAML input documents, producing policy judgments and returning values that match or do not match conditions. The language offers features like sets, object rules, functions, and iteration, which are explored in future blog posts. Rego is used by Snyk for custom IaC checks and is part of the Cloud Native Computing Foundation (CNCF).