Skip to main content

atmos validate component

Use this command to validate an Atmos component in a stack using JSON Schema and OPA policies.

Configure Schema Validation

Learn how to configure JSON Schema and OPA policy paths for validating components.

Usage

atmos validate component --help

Execute the validate component command like this:

atmos validate component <component> -s <stack> [options]

This command validates an Atmos component in a stack using JSON Schema and OPA policies.

Path-Based Component Resolution

Atmos supports using filesystem paths instead of component names for convenience:

# Navigate to component directory
cd components/terraform/vpc

# Use . to reference current directory
atmos validate component . --stack dev

This automatically resolves the path to the component name configured in your stack.

Supported path formats:

  • . - Current directory
  • ./component - Relative path from current directory
  • ../other-component - Relative path to sibling directory
  • /absolute/path/to/component - Absolute path

Requirements:

  • Must be inside a component directory under the configured base path
  • Must specify --stack flag
  • Component must exist in the specified stack configuration
  • The component path must resolve to a unique component name - If multiple components in the stack reference the same component path, you must use the unique component name instead of the path
Path Resolution Limitation

Path-based resolution only works when the component path resolves to a single unique component in the stack.

For example, if both station/1 and station/2 reference components/terraform/weather:

cd components/terraform/weather
atmos validate component . --stack dev # ❌ Error: ambiguous - which component?

Instead, you must use the unique component names:

atmos validate component station/1 --stack dev  # ✓ Explicit and unambiguous
atmos validate component station/2 --stack dev # ✓ Explicit and unambiguous
tip

Run atmos validate component --help to see all the available options

Examples

Component Name Examples

atmos validate component infra/vpc -s tenant1-ue2-dev
atmos validate component infra/vpc -s tenant1-ue2-dev --schema-path vpc/validate-infra-vpc-component.json --schema-type jsonschema
atmos validate component infra/vpc -s tenant1-ue2-dev --schema-path vpc/validate-infra-vpc-component.rego --schema-type opa
atmos validate component infra/vpc -s tenant1-ue2-dev --schema-path vpc/validate-infra-vpc-component.rego --schema-type opa --module-paths catalog/constants
atmos validate component infra/vpc -s tenant1-ue2-dev --schema-path vpc/validate-infra-vpc-component.rego --schema-type opa --module-paths catalog
atmos validate component infra/vpc -s tenant1-ue2-dev --timeout 15

Path-Based Examples

# Navigate to component directory and use current directory
cd components/terraform/vpc
atmos validate component . --stack dev

# Use relative path
cd components/terraform
atmos validate component ./vpc --stack dev

# Use from project root with relative path
atmos validate component components/terraform/vpc --stack dev

# Combine with validation options
cd components/terraform/vpc
atmos validate component . --stack dev --schema-path vpc-schema.json --schema-type jsonschema
atmos validate component . --stack dev --schema-path vpc-policy.rego --schema-type opa
atmos validate component . --stack dev --timeout 15

Arguments

component (required)

Atmos component name or filesystem path.

Supports both:

  • Component names: vpc, infra/vpc, test/test-component
  • Filesystem paths: . (current directory), ./vpc, components/terraform/vpc

When using paths, Atmos automatically resolves the path to the component name based on your stack configuration.

Flags

--stack / -s (required)
Atmos stack.
--schema-path (optional)
Path to the schema file.
Can be an absolute path or a path relative to schemas.jsonschema.base_path
and schemas.opa.base_path defined in atmos.yaml.
--schema-type (optional)
Schema type: jsonschema or opa.
--module-paths (optional)
Comma-separated string of filesystem paths (folders or individual files) to the additional modules
for schema validation. Each path can be an absolute path or a path relative to
schemas.opa.base_path defined in atmos.yaml.
--timeout (optional)
Validation timeout in seconds. Can also be specified in settings.validation component config. If not provided, timeout of 20 seconds is used by default.