Skip to main content
For background on policy concepts, types, and engines, see the Policies concept page.

Prerequisites

Before starting, ensure you have:
  • An existing Nuon app with at least one component (terraform, helm, or container_image)
  • The Nuon CLI installed and authenticated
  • Basic familiarity with OPA Rego syntax

Create the Policy Directory Structure

Create a policies/ directory in your app root to store policy files:
Your final directory structure will look like this:

Add a Container Image Policy (Build-time)

Container image policies validate external images during the build phase. This example requires all images to be cryptographically signed. Create policies/require-signed-images.rego:
policies/require-signed-images.rego
For detailed container image policy patterns including SBOM validation and attestation checks, see the External Image Policies guide.

Add a Terraform Policy (Deploy-time)

Terraform policies validate the Terraform plan before applying changes. This example requires S3 bucket encryption and warns about missing tags. Create policies/require-encryption.rego:
policies/require-encryption.rego

Add a Helm Chart Policy (Deploy-time)

Helm chart policies validate rendered Kubernetes manifests. This example requires CPU and memory limits on all containers. Create policies/require-resource-limits.rego:
policies/require-resource-limits.rego

Configure policies.toml

Create policies.toml at your app root to register each policy:
policies.toml

Policy configuration fields

The contents field supports multiple source types. Relative paths are resolved from the policies/ directory:

Sync Your App

Upload your policies by syncing your app:
Policies are synced along with components and other configuration. You should see output confirming the policies were uploaded:

Observe Build-Time Evaluation

Container image policies are evaluated when you create a build. Trigger a build for your image component:
If the image is not signed, the build fails with policy_failed status:
If the image passes all policy checks, the build succeeds:

Observe Deploy-Time Evaluation

Terraform and Helm policies are evaluated during deployment. Deploy your components to an install:
After the deployment starts, list the workflow steps to see policy results:
The output shows policy status for each step:
  • indicates deny violations that blocked the step
  • indicates warnings that were logged but allowed the step to continue
  • indicates all policies passed
Get detailed violation messages for a specific step:

View Results in Dashboard

Policy results are also visible in the Nuon Dashboard:
  1. Navigate to your install’s Workflows tab
  2. Select the workflow run
  3. Click on a workflow step to view details
  4. The Policy Report card shows:
    • Passed: Green checkmark if all policies passed
    • Denies: Red indicators with violation messages
    • Warnings: Orange indicators with warning messages
Each violation displays the policy name and the specific message from your deny or warn rule. Workflow policy violations
You can also view policy results via CLI using nuon installs workflows steps get -w <workflow-id> -s <step-id>.

Fix Policy Violations

To resolve policy violations, update your components to comply with the policies: For container images: Sign your images using cosign or another signing tool before pushing to your registry. For Terraform: Add the required configuration to your module:
For Helm charts: Add resource limits to your pod specs:
After making changes, sync and redeploy:
Confirm the policies now pass:

Next Steps