One variables.yml to rule them all

Connor Kerling

6 min read.

December 3, 2026

CONTENTS

One variables.yml to rule them all

When I first had to migrate my notebooks across environments and add them to a bundle, I quickly realised just how many values I’d hardcoded without a second thought. Catalog names, schema names and volume paths were all buried in notebook cells.

Only afterwards did I realise how useful variables are in Declarative Automation Bundles (DABs). By keeping all your variables in a single variables.yml file and referencing them across your jobs, pipelines and notebooks, promoting code between environments has never been easier.

In this post, I’ll walk through the pattern that saved me from having to find and replace my way through every notebook each time I deployed, reducing deployment overhead and keeping environment promotion consistent across the project.

The project structure

Here’s the directory structure we use for this blog.

my-project/
databricks.yml
resources/
variables.yml
job/
ingest_bronze.yml
pipeline/
ingest_data.yml
src/
ingest_bronze.ipynb
ingest_data.py

Directory
File

 

Updating the same value in five different places is cumbersome. So, we define everything once in resources/variables.yml, reference it in our job and pipeline configs, and pull it into our notebooks at runtime. Let’s walk through the steps to get a better understanding.

Step 1: Define your variables centrally

resources/variables.yml

variables:
  catalog:
    description: "Unity Catalog catalog name"
    default: dev_catalog

  schema:
    description: "Target schema"
    default: bronze

  storage_path:
    description: "Volume path for raw data"
    default: /Volumes/dev_catalog/bronze/raw

  notification_email:
    description: "Email for job failure alerts"
    default: dev-team@company.com

 

Step 2: Include it in databricks.yml

databricks.yml

bundle:
  name: my-project

include:
  - resources/variables.yml
  - resources/job/*.yml
  - resources/pipeline/*.yml

targets:
  dev:
    mode: development
    default: true
    workspace:
      host: https://adb-dev.azuredatabricks.net
    # Dev uses the defaults from variables.yml

  prod:
    mode: production
    workspace:
      host: https://adb-prod.azuredatabricks.net
    # Override variables for prod
    variables:
      catalog: prod_catalog
      schema: bronze
      storage_path: /Volumes/prod_catalog/bronze/raw
      notification_email: prod-alerts@company.com

 

The include lines pull in your variable definitions and resource configurations. The targets section is where you override variable values per environment. Dev uses the defaults. Prod overrides them. It’s as simple as that.

Step 3: Define a job using variables

resources/job/create_bronze.yml

resources:
  jobs:
    create_bronze_job:
      name: create-bronze-${bundle.target}
      parameters:
        - name: catalog
          default: ${var.catalog}
        - name: schema
          default: ${var.schema}
        - name: storage_path
          default: ${var.storage_path}
      tasks:
        - task_key: create_bronze
          notebook_task:
            notebook_path: ../src/create_bronze.py
      email_notifications:
        on_failure:
          - ${var.notification_email}

 

The key here is the use of job-level parameters (you can also define parameters at the task level). By using job-level parameters, we can pass bundle variables through to our notebooks, where they become accessible as widgets at runtime.

Step 4: Consume job parameters in a notebook

src/create_bronze.py

CATALOG = dbutils.widgets.get("catalog")
SCHEMA = dbutils.widgets.get("schema")
STORAGE_PATH = dbutils.widgets.get("storage_path")

spark.sql(f"USE CATALOG {CATALOG}")
spark.sql(f"USE SCHEMA {SCHEMA}")

df = spark.read.format("json").load(STORAGE_PATH)
df.write.mode("overwrite").saveAsTable(f"{CATALOG}.{SCHEMA}.create_bronze_job")

 

Step 5: Define a pipeline using variables

resources/pipeline/create_bronze.yml

resources:
  pipelines:
    create_bronze_pipeline:
      name: create-bronze-${bundle.target}
      catalog: ${var.catalog}
      schema: ${var.schema}
      libraries:
        - notebook:
            path: ../src/create_bronze.ipynb
      configuration:
        storage_path: ${var.storage_path}

 

For pipelines, we pass variables through the configuration map so that they become available as Spark conf values inside the pipeline code. This means the same pipeline can run across dev, test and prod without hardcoding environment-specific values or maintaining separate pipeline definitions.

Step 6: Consume pipeline configuration in a DLT pipeline

src/create_bronze.ipynb

from pyspark import pipelines as dp


STORAGE_PATH = spark.conf.get("storage_path")

@dp.materialized_view(
    comment="Cleaned bronze events"
)
def create_bronze_pipeline():
    return spark.read.format("json").load(STORAGE_PATH)

 

Two patterns, one principle

Notice the two approaches:

  • Jobs: pass variables as job/task parameters, consume with dbutils.widgets.get()

  • Pipelines: pass variables as configuration, consume with spark.conf.get()

Both achieve the same thing: your code stays the same across every environment.

Promoting to production

When you’re ready to deploy to prod, nothing changes in your notebooks or resource definitions because the environment-specific values are handled entirely through bundle variables. Switching environments is just a matter of deploying to a different target:

databricks bundle deploy -t prod

 

DABs resolve ${var.catalog} to prod_catalog, ${var.storage_path} to /Volumes/prod_catalog/bronze/raw, and so on. Your jobs and pipelines are created with production values. Pat yourself on the back.

The takeaway

The initial setup is straightforward: a single variables.yml file and a few ${var.*} references across your bundle resources. In return, every job, pipeline and notebook added to the project follows a consistent configuration pattern automatically. This removes the need for manual find-and-replace updates during deployments and avoids maintaining separate environment-specific notebook versions.

From a developer perspective, this approach simplifies deployments, reduces repetitive configuration tasks and minimises the risk of errors introduced through hardcoded values. Teams can spend less time troubleshooting configuration drift and more time delivering features.

From a business and operational perspective, centralised variable management improves deployment consistency and supports more reliable release processes across environments. As projects scale, this standardisation reduces maintenance overhead, improves governance and enables teams to onboard new workloads with less operational complexity.

The earlier this pattern is adopted, the easier it becomes to scale and maintain your Databricks projects over time.

Plan your variables early. Your future self will thank you.

Get in touch with our team, today

top