Pulumi CrossGuard

The landscape of modern cloud infrastructure is characterized by an unprecedented shift toward self-service provisioning, where developers and operators are empowered to deploy resources rapidly to meet business demands. However, as infrastructure codebases scale across diverse teams and multiple environments, this speed introduces significant risks. Ensuring that every deployed resource adheres to strict corporate security standards, regulatory compliance requirements, and cost constraints becomes a critical bottleneck. Traditionally, organizations relied on manual code reviews, which are inherently slow and error-prone, or runtime scanners that only detect vulnerabilities after a resource is already live and potentially exposed. Pulumi CrossGuard emerges as the native Policy as Code (PaC) framework designed to solve these challenges by shifting governance "left." By integrating policy enforcement directly into the infrastructure deployment lifecycle, CrossGuard allows platform engineers, security teams, and cloud architects to define automated guardrails that prevent non-compliant resources from ever reaching the cloud.

The Architecture of Policy as Code

Pulumi CrossGuard is not a standalone utility but a policy-as-code solution deeply integrated into the Pulumi platform. At its core, it allows the expression of flexible business and security rules using familiar, general-purpose programming languages. Unlike traditional policy engines that may require learning a proprietary domain-specific language (DSL), CrossGuard leverages the power of TypeScript, Python, and Go.

The implementation of CrossGuard transforms policy from a static document or a manual checklist into executable code. This transition enables organizations to treat their compliance rules with the same rigor as their application code, utilizing version control, automated testing, and collaborative review processes. By doing so, the governance of cloud infrastructure becomes programmable and scalable, removing the reliance on human intervention for every single resource change.

Language Support and Cross-Language Interoperability

One of the most significant technical advantages of Pulumi CrossGuard is its decoupled nature regarding programming languages. The framework allows users to author policy packs in specific languages while applying them to infrastructure stacks written in entirely different languages.

The following table outlines the primary languages supported for authoring policy packs:

Language Support Status Use Case
TypeScript Fully Supported High-performance, strongly-typed policy definitions
JavaScript Fully Supported Flexible, lightweight policy authoring
Python Fully Supported Data-science friendly, widely adopted scripting
Go Fully Supported Systems-level performance for policy execution

This interoperability means that a security team can develop a comprehensive set of organizational policies in TypeScript, and these policies will be seamlessly run against a Pulumi stack authored in Python. This removes the friction of forcing every development team to use a single language, allowing for a heterogeneous environment where the "policy language" is separated from the "infrastructure language."

The Policy Pack Mechanism

Policies in CrossGuard are organized into entities known as Policy Packs. A Policy Pack is a collection of configurable compliance rules that are grouped together and executed against a Pulumi stack. These packs act as the primary unit of policy distribution and enforcement across an organization.

The execution of Policy Packs occurs during two critical phases of the Pulumi lifecycle:

  • pulumi preview
  • pulumi up

By running policies during the pulumi preview phase, CrossGuard can identify violations before any actual changes are made to the cloud environment. This provides real-time feedback to the developer, allowing them to correct the configuration before the deployment process begins. When executed during pulumi up, the Policy Pack serves as a final gate, ensuring that no out-of-compliance resource is created. This proactive approach effectively blocks the creation of resources that violate security or cost mandates, ensuring the cloud environment remains in a known-good state.

Configurable Enforcement Levels

Pulumi CrossGuard provides granular control over how policies are enforced through three distinct levels. This flexibility allows administrators to balance the need for strict security with the need for developer velocity.

The available enforcement levels are:

  • Mandatory: These rules are strictly enforced. If a resource violates a mandatory policy, the deployment is blocked entirely, and the resource cannot be created. This is critical for regulatory issues or high-risk security vulnerabilities.
  • Advisory: These rules serve as warnings. If a resource violates an advisory policy, the user is notified of the organization's practices, but the deployment is allowed to proceed. This is ideal for encouraging best practices without halting productivity.
  • Disabled: These rules are inactive and will not trigger any notifications or block any deployments.

Users have the ability to set a default enforcement level for all policies within a pack and then override specific rules as needed. For example, an organization might set the default level to "advisory" to educate their teams on optimal cloud patterns while specifically designating encryption rules as "mandatory" to satisfy legal compliance.

AWSGuard and Pre-built Policy Solutions

To accelerate the adoption of Policy as Code, Pulumi provides AWSGuard, an open-source policy pack written in TypeScript. AWSGuard encapsulates common AWS best practices, allowing users to implement a baseline of security and operational excellence without writing every rule from scratch.

AWSGuard serves as a primary example of how configurable policies can be deployed. Users can integrate AWSGuard into their workflow and then customize the enforcement levels (mandatory, advisory, or disabled) based on their specific organizational needs. Beyond AWSGuard, the framework supports the creation of custom policy packs. For instance, a team can author a custom pack in Python to enforce specific internal naming conventions or cost-saving constraints that are unique to their business model.

Strategic Use Cases for CrossGuard

The application of Pulumi CrossGuard spans several domains, primarily focusing on security, cost management, and operational stability.

  • S3 Bucket Encryption: A common security requirement is ensuring that all S3 buckets have encryption enabled. CrossGuard can enforce a mandatory policy that checks every S3 bucket resource during the preview phase; if encryption is missing, the deployment is blocked.
  • Cost Control and VM Restrictions: To prevent budget overruns, organizations can restrict the use of expensive virtual machine types. CrossGuard can be programmed to flag or block the deployment of high-cost instance types, ensuring that developers use cost-effective resources.
  • Shift-Left Governance: By integrating policies into the IDE and CI/CD pipelines, governance is shifted "left" in the development process. This means errors are caught at the earliest possible stage, reducing the cost of remediation and preventing the "deployment-failure-fix" loop.

Integration and Deployment Ecosystem

Pulumi CrossGuard is designed to fit into diverse operational workflows, whether the organization is using a local development setup or a complex enterprise CI/CD pipeline.

  • IDE Integration: CrossGuard provides real-time feedback within the IDE. This allows developers to see policy violations as they write their infrastructure code, further reducing the time spent waiting for CI/CD feedback.
  • CI/CD Pipeline Enforcement: Policy packs can be integrated directly into CI/CD pipelines. This ensures that every commit is validated against the organizational policy set before it is merged or deployed.
  • Server-Side Enforcement: For organizations requiring higher levels of governance, CrossGuard can be enforced server-side as part of Pulumi's Business Critical service offering. This provides a centralized point of control where policies are enforced regardless of where the deployment is triggered.
  • Open Source Accessibility: CrossGuard is 100% open source and available to all users, including those using the Individual Edition. This allows individuals and small teams to benefit from Policy as Code without an initial financial barrier.
  • Enterprise Management: Advanced organization-wide policy management features are available to Enterprise customers, enabling administrators to manage policies across multiple stacks and organizations from a centralized "Policies" tab in the Pulumi Service.

Competitive Landscape and Tooling Comparison

While Pulumi CrossGuard provides a native, integrated experience for Pulumi users, several other tools exist in the IaC compliance ecosystem. Most of these tools focus on static analysis of configuration files rather than dynamic evaluation within a programming language framework.

The following table compares Pulumi CrossGuard with other popular IaC compliance tools:

Tool Primary Approach Focus
Snyk IaC Static Analysis Finding security issues in Terraform, CloudFormation, etc.
Checkov Static Analysis Open-source analysis of IaC files
Terrascan Static Analysis Open-source static code analyzer for IaC
KICS by Checkmarx Static Analysis Open-source static analysis for IaC
tfsec Static Analysis Specifically targeted at Terraform code
Open Policy Agent General Purpose Engine Broad, general-purpose policy engine

The key differentiator for CrossGuard is its deep integration with the Pulumi platform and its use of general-purpose programming languages, which allows for more complex, dynamic, and flexible policy logic compared to the static analysis provided by tools like tfsec or Checkov.

Technical Implementation Analysis

The transition from manual reviews to Pulumi CrossGuard represents a fundamental shift in how cloud infrastructure is managed. By treating policy as code, organizations can eliminate the "bottleneck" effect of security audits.

When a user executes pulumi preview, the Pulumi engine analyzes the desired state of the infrastructure. Before the plan is finalized, the CrossGuard framework intercepts the resource definitions and runs them through the active Policy Packs. Each resource is evaluated against the rules defined in the pack. If a rule is set to "mandatory" and the resource fails the check, the engine generates a failure report and halts the process.

This mechanism ensures that the infrastructure as it exists is transitioned into the declared desired state only if that state is compliant. This is a stark contrast to runtime scanners, which only identify the "desired state" as a "violated state" after the resource has been provisioned. By the time a runtime scanner detects a public S3 bucket, the data may already be compromised. CrossGuard prevents the bucket from being public in the first place.

Detailed Analysis of Policy Governance

The deployment of Pulumi CrossGuard allows for a tiered approach to governance. In a large-scale organization, this manifests as a layered security model.

At the lowest layer, individual developers use the IDE integration to catch simple errors. At the middle layer, team-specific Policy Packs enforce project-level constraints. At the highest layer, the organization-wide "Business Critical" server-side enforcement ensures that non-negotiable regulatory requirements are met across every single stack in the company.

This hierarchical structure prevents the "governance fatigue" that occurs when too many rules are applied indiscriminately. By using "advisory" labels for suggested improvements and "mandatory" labels for critical security flaws, organizations can maintain a high velocity of deployment while guaranteeing a hard floor of security.

The result is a continuous compliance cycle. As new security threats emerge or new regulatory requirements are introduced (such as changes in GDPR or HIPAA), the security team can simply update the Policy Pack. Once the pack is updated, every subsequent pulumi preview across the entire organization will immediately reflect the new requirements, ensuring a rapid and synchronized response to compliance changes.

Sources

  1. Pulumi CrossGuard
  2. Announcing CrossGuard Preview
  3. Continuous Compliance at Scale in AWS CI/CD Pipelines using Pulumi CrossGuard
  4. CrossGuard and Policy as Code
  5. Policy as Code CrossGuard

Related Posts