Establish Cyber Resilience with Policy as Code
When it comes to cloud native architecture, the one constant we can count on is change. Complex systems need a comprehensive, proactive security approach, and that is where Policy as Code (PaC) comes into play. Policy as Code takes the policies that are most important to your organization, codifies them with your applications, and enforces them consistently and automatically throughout the application lifecycle. Integrating PaC into your infrastructure provisioning process allows potential threats to be detected and resolved early. Compliance with regulatory and organizational requirements can be ensured. And, combining PaC with immutable infrastructure means increased velocity with decreased risk. Let’s take a look at how Policy as Code can be applied to every stage of a cloud application’s life cycle, ensuring best practices are embedded throughout.
Policy as Code in the design phase
Organizations know they need to start thinking about security early in the design process and PaC supports this effort. As you design your architecture to meet your business objectives and start building IaC templates, PaC tools can analyze those templates to provide insights into the topology, and ensure security and operational best practices are followed. Analysis informs threat modeling, helping you identify potential threats and select or build policies to manage those risks. Open source frameworks like Open Policy Agent (OPA) enable you to codify those policies as code to address risks including access management, auditability, and data protection.
The sheer number of potential security and operational issues across IaC languages and platforms can be daunting, but PaC tools such as Terrascan are designed to simplify the task. Using OPA as its policy engine, Terrascan offers more than 500 pre-built policies that address common risks and it is easily extensible. This gives you the flexibility to decide exactly which policies to use when evaluating your systems. Engineers can evaluate compliance locally to verify IaC templates during development, or the process can be automated through pre-commit hooks that identify violations before they’re introduced into source code repositories, and through plug-ins that integrate directly with IDEs.
Policy as Code in the build phase
Integrating PaC into your build time checks in CI/CD pipelines will ensure your security governance scales with your system’s changes. This is done by executing the tooling within the context of a CI job, which should be configured to enforce specific, important policies. Codifying these policies as PaC ensures the configurations are consistent throughout development. Be sure to establish constraints on the CI process that ensure the PaC configuration can’t be changed to bypass policies. Using the server mode in Terrascan accomplishes this by decoupling the PaC configuration from the CI job. Code is sent to a server pre-configured with relevant policies, which is analyzed outside the CI runtime environment.
Modern platforms, like Accurics, pair PaC enforcement with advanced capabilities such as Remediation as Code (RaC) to greatly improve the number of issues that are actually fixed. Where PaC detects issues in your IaC, RaC generates a pull request for each finding which includes the IaC remediation code so teams can quickly and easily resolve the problem at the source. This programmatic approach ensures that fixes can be implemented at scale without slowing down deliveries.
Policy as Code in runtime
Leveraging PaC during development will not only reduce security risks introduced in your runtime environment during normal deployment situations, it can also protect it from risks introduced through unplanned work or malicious changes. Cloud vendors often provide capabilities, such as AWS identity and access management permission boundaries, which let you limit the impact of privilege escalation by establishing boundaries for specific entities within your environment using JSON policies. In Kubernetes, you can also leverage capabilities like Terrascan’s validating admission controller to reject changes that don’t comply with policies.
The ultimate goal is to create an infrastructure that is self-healing – meaning that policy violations are identified and programmatically addressed, ensuring your environment always remains in compliance. Drift as Code (DaC) helps to ensure that IaC remains up-to-date even as the runtime configuration evolves through compliant changes. Security as Code (SaC) moves beyond PaC, assessing security risks holistically based on context and possible breach paths to prioritize exploitable vulnerabilities and recognize optimal remediation steps.
Cloud native architecture is only going to continue growing in complexity and popularity, so organizations need a comprehensive security approach that can scale with that growth. Policy as Code delivers consistent, auditable governance throughout the lifecycle, all to increase efficiency and reduce the risk of error. Applying PaC to every stage of a system’s lifecycle ensures your best practices and security policies are codified and automatically enforced. When enhanced with Accurics’ Security as Code (SaC), Drift as Code (DaC), and Remediation as Code (RaC) solutions, you have the capabilities needed to create a self-healing infrastructure. These immutable infrastructure practices will significantly reduce your organization’s security risks and will allow you to establish and maintain a cyber resilient environment.
For a deeper dive into how PaC augments enterprise scale cloud projects, please check out our Enterprise Guide to Policy as Code: Design, Build, and Runtime.