Skip to main content

Validate Configurations

Atmos supports Stack Schema Validation and Custom Policy Validation using JSON Schema and OPA Policies.

tip

This Quick Start guide describes the steps to configure and provision the infrastructure from the Quick Start repository.

You can clone the repository and modify to your own needs. The repository will help you understand the validation configurations for Atmos manifests and components.

Configuring validation for Atmos manifests and components consists of the three steps:

  • Configure validation schemas in atmos.yaml
  • Configure Atmos manifests validation
  • Configure Atmos components validation

Configure Validation Schemas in atmos.yaml

In atmos.yaml CLI config file, add the schemas section as shown below:

atmos.yaml
# Validation schemas (for validating atmos stacks and components)
schemas:
# https://json-schema.org
jsonschema:
# Can also be set using 'ATMOS_SCHEMAS_JSONSCHEMA_BASE_PATH' ENV var, or '--schemas-jsonschema-dir' command-line arguments
# Supports both absolute and relative paths
base_path: "stacks/schemas/jsonschema"
# https://www.openpolicyagent.org
opa:
# Can also be set using 'ATMOS_SCHEMAS_OPA_BASE_PATH' ENV var, or '--schemas-opa-dir' command-line arguments
# Supports both absolute and relative paths
base_path: "stacks/schemas/opa"
# JSON Schema to validate Atmos manifests
# https://atmos.tools/cli/schemas/
# https://atmos.tools/cli/commands/validate/stacks/
# https://atmos.tools/quick-start/advanced/configure-validation/
# https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json
# https://json-schema.org/draft/2020-12/release-notes
atmos:
# Can also be set using 'ATMOS_SCHEMAS_ATMOS_MANIFEST' ENV var, or '--schemas-atmos-manifest' command-line arguments
# Supports both absolute and relative paths (relative to the `base_path` setting in `atmos.yaml`)
manifest: "stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"
tip

For more information, refer to:

Configure Atmos Manifests Validation

Atmos Manifest JSON Schema can be used to validate Atmos stack manifests and provide auto-completion in IDEs and editors.

Complete the following steps to configure Atmos manifest validation:

  • Add the Atmos Manifest JSON Schema to your repository, for example in stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json

  • Configure the schemas.atmos.manifest section in the atmos.yaml CLI config file as described in Atmos Manifests Validation using JSON Schema

    atmos.yaml
    # Validation schemas (for validating atmos stacks and components)
    schemas:
    atmos:
    # Can also be set using 'ATMOS_SCHEMAS_ATMOS_MANIFEST' ENV var, or '--schemas-atmos-manifest' command-line arguments
    # Supports both absolute and relative paths (relative to the `base_path` setting in `atmos.yaml`)
    manifest: "stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"
  • Execute the command atmos validate stacks

  • Instead of configuring the schemas.atmos.manifest section in atmos.yaml, you can provide the path to the Atmos Manifest JSON Schema file by using the ENV variable ATMOS_SCHEMAS_ATMOS_MANIFEST or the --schemas-atmos-manifest command line argument:

    ATMOS_SCHEMAS_ATMOS_MANIFEST=stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json atmos validate stacks
    atmos validate stacks --schemas-atmos-manifest stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json

Configure Atmos Components Validation

Atmos component validation allows:

  • Validate component config (vars, settings, backend, env, overrides and other sections) using JSON Schema

  • Check if the component config (including relations between different component variables) is correct to allow or deny component provisioning using OPA Policies

To configure Atmos components validation, complete the steps described in Custom Policy Validation.

tip

For more information, refer to: