Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Projections

Use this guide to understand and build projections in DataOS for runtime dynamic configurations.

What are projections?

Projections are a DataOS templating system that injects configuration files, environment variables, and command arguments into your containers at runtime.

Instead of hardcoding values such as database URLs, API keys, Spark settings, configuration files, or command arguments directly inside a resource, you can define them as templates. At runtime, DataOS fills those templates using values from secrets, depots, addresses, default DataOS context, and application configuration.

What Can Projections Do?

  • Generate configuration files dynamically

  • Inject environment variables from secrets

  • Modify command arguments

  • Access data from depots (data sources)

  • Adapt to different environments automatically

When should you use projections?

Use projections when your workload needs configuration that changes across environments, tenants, depots, secrets, or runtime contexts.

In simple terms:

Template + Runtime context = Container-ready configuration

Use projections when you need to:

  • Inject secret values into a container without hardcoding them.

  • Generate config files at runtime.

  • Build environment-specific settings from the DataOS context.

  • Use depot connection details inside an application or stack.

  • Pass dynamic command arguments to a container.

  • Keep the same stack or resource reusable across different tenants or environments.

The Problem Projections Solve

Without projections, you’d need to hardcode configuration:

Problems with static configuration:

  • Security risk: Credentials exposed in YAML

  • Environment coupling: Different configs for dev/staging/prod

  • Maintenance overhead: Manual updates for each environment

  • No dynamic adaptation: Can’t adapt to runtime context

The Projection Solution

With projections, configuration becomes dynamic and secure:

Benefits of projections:

  • Secure: Credentials come from DataOS secrets

  • Environment-agnostic: Same config works across environments

  • Dynamic: Adapts to runtime context automatically

  • Maintainable: Single source of truth

Template Engine Support

Every projection item carries its content in the template field. There is no value field: an item without template fails validation with envVar template is required.

Set the optional templateType field to choose how template is processed. DataOS supports two values:

Liquid is the default. Reference context values without a leading dot.

Use Liquid for secrets, runtime context, filters such as base64_decode and default, and conditionals.

Use none when the value should be treated as static text.

Projection building blocks

A projection has three main parts:

Example:

In this example:

  • templateType tells DataOS to use Liquid syntax. Liquid is the default, so you can omit this line.

  • secrets tells DataOS which secret to load.

  • contextAlias: "db" makes the secret available as secrets['db'].

  • envVars generates an environment variable for the container. key sets the variable name and template sets its content.

  • DATABASE_URL is built dynamically at runtime.

Developer workflow

1. Decide what needs to be dynamic

Start by identifying which values should not be hardcoded.

Common examples:

  • Database username and password

  • API tokens

  • Tenant-specific URLs

  • Spark configuration

  • Depot connection details

  • Environment-specific log levels

  • Config files used by an application

2. Choose where to define the projection

Projections can be defined at two levels:

Stack-level projection: The projection applies to every job, Service, and Worker that uses the stack.

Application-level projection: The projection is specific to one workload.

If both levels define a projection, both run. When both produce an environment variable with the same name, the application-level value wins.

3. Add data sources

Add the runtime data your template needs.

Common sources include:

  • Secrets

  • Depots

  • Addresses

  • Default DataOS context

  • Application context

  • Stack spec values

4. Define what the projection generates

A projection can generate one or more of the following:

a. Environment Variables

Individual Variables

Use key (or keyTemplate) for the variable name and template for its content.

b. Configuration Files

Individual Files

c. Command Arguments

d. Dictionary Values

5. Test locally

The DataOS CLI provides two commands for developing and testing projections locally. Use these to prototype and test:

dataos develop use - Test Projection Logic

dataos develop resource - Test Full Resource Definitions

6. Deploy after validation

Apply your tested projections to actual resources.

Quick start with DataOS CLI

Before adding projections to a real workload, test them locally.

Test projection logic

Use dataos develop use when you want to test only the projection template.

Test a full resource

Use dataos develop resource when you want to validate a complete resource definition that includes projections.

Data sources

Secrets

Use secrets for sensitive values such as passwords, tokens, usernames, and API keys.

With the alias db, the secret can be referenced as:

Depots

Use depots when the projection needs information about a data source.

Use includeSecrets: true only when the projected output needs depot secret values.

Addresses

Use addresses when the projection needs to reference DataOS dataset or depot addresses.

Available template variables

Default DataOS context

Use defaultProjections when you need platform-provided values such as tenant IDs, namespace, resource details, service URLs, cloud provider details, Spark event log settings, or standard DataOS paths.

Application context

Secrets context

Secret values are base64-encoded in the projection context. Add | base64_decode to get the plain value, for example {{ secrets['myAlias'].key | base64_decode }}.

Depots context

Complete examples

Example 1: Database configuration

This example builds a database URL and a database config file from a secret. Use this pattern when your application needs database connection settings but the credentials should stay in DataOS secrets.

Example 2: Multi-cloud Spark configuration

This example generates Spark configuration based on the cloud environment and Spark event log settings. Use this pattern when the same workload needs to run across AWS, Azure, or GCP without maintaining separate config files.

Example 3: DataOS-specific patterns

Icebase connection

This pattern references an Icebase address and uses depot connection details in the generated output.

Depot integration

This pattern loads depot metadata and secrets, then writes them into a generated config file.

How it works under the hood

See How projections work for the runtime flow, generated output, and default mount paths.

Additional guidance

Use these companion pages when you move from setup to production use:

Last updated

Was this helpful?