Compliance as Code
Compliance as Code is the practice of expressing regulatory and policy requirements as machine-readable code so that compliance checks can be automated rather than performed manually. This approach allows organizations to continuously and consistently verify that their systems, infrastructure, and software meet required standards. By embedding compliance rules directly into development and deployment workflows, teams can detect violations earlier and reduce the effort needed for audits.
Compliance as Code refers to the codification of regulatory, organizational, and security compliance requirements into executable policy definitions that can be evaluated automatically against infrastructure configurations, application code, and deployment artifacts. Unlike Policy as Code, which focuses on encoding and enforcing individual policies, Compliance as Code typically takes a broader perspective, mapping codified checks to specific regulatory frameworks or standards and generating evidence of adherence. These checks may operate at the static or configuration level (for example, validating Infrastructure as Code templates or source code against known compliance violations) but may not detect all compliance issues that require runtime or deployment context, such as actual network behavior or data flow patterns observable only in a live environment. Tooling in this space, such as the ComplianceAsCode/content project, provides reusable compliance content that can be integrated into CI/CD pipelines to automatically demonstrate that new code and configurations comply with relevant policies and regulations.
Why it matters
In regulated industries such as finance, healthcare, and government, organizations must continuously demonstrate adherence to frameworks like PCI DSS, HIPAA, FedRAMP, and SOC 2. Traditionally, compliance verification has been a labor-intensive, periodic process involving manual documentation reviews and audits that can take weeks or months. During these gaps between assessments, configuration drift and newly introduced code changes may silently violate compliance requirements, leaving organizations exposed to both security risk and regulatory penalties. Compliance as Code addresses this by shifting compliance verification into the development and deployment lifecycle, enabling teams to catch violations closer to the point of introduction rather than discovering them during an audit cycle.
By codifying compliance checks, organizations also gain consistency and repeatability. Manual compliance reviews are prone to human error and subjective interpretation, which can lead to inconsistent enforcement across teams or environments. When compliance requirements are expressed as executable code, every system and artifact is evaluated against the same rule set every time, reducing variance. This approach can also significantly reduce audit preparation effort, since the automated checks themselves serve as continuously generated evidence of adherence. However, it is important to recognize that not all compliance requirements can be fully verified through static or configuration-level checks alone. Requirements that depend on runtime behavior, actual network traffic patterns, or data flow observations in live environments may still require supplementary verification methods beyond what Compliance as Code tooling typically provides.
Who it's relevant to
Inside CaC
Common questions
Answers to the questions practitioners most commonly ask about CaC.