What you will be able to do
- Read a databricks.yml and name the bundle, resources, variables and targets it defines
- Predict which target a bundle command deploys to when -t is omitted, and how target settings override top-level resources
- Resolve a bundle variable's value using the CLI's five-step lookup order, including BUNDLE_VAR_ environment variables
- Tell apart the behaviours of development mode, production mode and presets
- Choose the right bundle command (validate, deploy, run, destroy) and explain how deployment state and root_path decide which workspace objects a deploy touches
- Declare wheel, PyPI and environment dependencies inside bundle job resources so that deployed runs install them reproducibly
Key concept
Bundle deployment to a target — A bundle is a YAML description of a project's Databricks resources and source files. The CLI deploys it as one unit to a named target, and each target can change the workspace, variables, mode or resources for that environment.
1.What a bundle is and where its configuration lives
Declarative Automation Bundles, formerly Databricks Asset Bundles, let you manage Databricks projects as infrastructure as code. Jobs, Lakeflow pipelines, dashboards, schemas, volumes and other workspace objects are described in YAML that sits next to the notebooks and Python files they run. Because that YAML lives in source control, a job definition goes through the same review, testing and CI/CD as the code it runs. Bundles suit team projects where several people contribute and deployments are automated. A one-off job built by one person in the UI gains little from them.
**Every bundle has exactly one databricks.yml at the project root.** That file must name the bundle under the required bundle mapping, and it usually declares at least one target. It can pull in other YAML files through include, so a large project can keep each job in its own file and the targets in another. The CLI merges all of them into one configuration. The smallest valid bundle needs only a name and a target:
bundle:
name: my_bundle
targets:
dev:
default: true**Resources are declared under the resources mapping, keyed by type and then by a unique key you choose**: jobs, pipelines, schemas, volumes, dashboards and so on. A resource's keys are the create-request fields of its REST API object written as YAML. A job resource therefore takes the same tasks, notebook_task and existing_cluster_id fields the Jobs API accepts. Other top-level mappings include variables for values that change between environments, run_as and permissions for identities, artifacts for things the CLI builds (such as wheels), sync for which files to upload, and workspace for host and path settings. You don't have to write all of this by hand. databricks bundle init creates a project from a template, and databricks bundle generate writes YAML for a job or pipeline that already exists in the workspace.
Checkpoint 1 of 9· Fill the gap
This is the smallest valid databricks.yml: a required bundle name and one target that the CLI uses when no target is given. Which key completes it?
bundle:
name: my_bundle
targets:
dev:
? : truedefault: true makes dev the target the CLI uses when you run a bundle command without -t. The mode key takes a value such as development or production, not a boolean. It does not choose which target is used.
2.Targets: one bundle, several environments
**A target is a named environment, such as dev, staging or prod, that can override any top-level setting.** Top-level resources, workspace, variables and artifacts act as defaults. Each entry under targets changes only what differs for that environment. In the example below, prod points at a different workspace host and swaps in a different cluster ID for the task. It never restates the notebook_task, because anything a target leaves out falls back to the top-level definition.
targets:
dev:
default: true
prod:
workspace:
host: https://<production-workspace-url>
resources:
jobs:
hello-job:
name: hello-job
tasks:
- task_key: hello-task
existing_cluster_id: 2345-678901-fabcd456**The -t (or --target) flag picks the target. Leaving it out sends the command to the single target marked default: true.** Only one target may be the default. The CLI does not deploy to every target, does not prefer the last one listed, and does not fail just because several targets exist. To deploy anywhere other than the default, name the target explicitly:
# You must specify "-t prod", because the "dev" target
# is already set to "default: true":
databricks bundle validate
databricks bundle deploy -t prod
databricks bundle run -t prod hello_jobPrefer workspace.host in each target over hard-coding a CLI profile. Given a host, the CLI finds the matching profile in .databrickscfg and uses that profile's authentication, so the same bundle works on any machine that has credentials for the host. You only need --profile if several profiles share the same host. Note that --profile (-p) selects authentication and has nothing to do with bundle variables.
Checkpoint 2 of 9· Check yourself
Top-level resources define hello-job with a notebook_task (./hello.py) on cluster 1234-567890-abcde123. The prod target sets a different workspace host and gives hello-task only existing_cluster_id 2345-678901-fabcd456. After databricks bundle deploy -t prod, what does the prod job run?
A target changes only what it restates. The prod cluster ID replaces the top-level one, and notebook_task, which prod leaves out, comes from the top-level definition.
“it falls back to use the notebook_task mapping within the top-level resources mapping, if the notebook_task mapping is not explicitly overridden within the prod mapping”Source: docs.databricks.com
Checkpoint 3 of 9· Exam question
A platform team maintains a Declarative Automation Bundle with the following databricks.yml targets block:
targets:
dev:
default: true
workspace:
host: https://dev-workspace.cloud.databricks.com
prod:
workspace:
host: https://prod-workspace.cloud.databricks.com
An engineer runs databricks bundle deploy from the repository root without passing a -t flag. Which target receives the deployment?
Correct answer: A — The dev target, because it is the only target marked default: true and the CLI resolves an omitted -t flag to that target automatically.
- A. Exactly one target may be marked
default: true, and when-tis omitted the CLI resolves the deployment to that target, so this bundle deploys todevwithout any further input from the engineer. - B. Target resolution does not depend on declaration order; the CLI looks for a target flagged
default: truerather than falling back to whichever target happens to appear last in the file. - C. An omitted
-tflag is only an error when no target in the file is marked as the default; since one target is explicitly flaggeddefault: truehere, the CLI has an unambiguous target to resolve to and proceeds. - D. Each bundle deploy command targets exactly one target per invocation; there is no fan-out behavior that deploys the same bundle configuration to multiple targets in a single command.
3.Custom variables and how the CLI resolves them
Custom variables put values that change between environments, such as warehouse IDs, catalog names and schema names, in one place. You declare each variable under the top-level variables mapping with a description and an optional default, and you reference it anywhere as ${var.<name>}. A target can give a variable a different value under its own variables mapping. Variables are strings unless you set type: complex, which is the only valid value for type. With it, a variable can hold a structure such as a full cluster definition.
The CLI checks five places in a fixed order and stops at the first value it finds. The order explains a common CI pattern. A pipeline that needs a different value on every run can export BUNDLE_VAR_<name> before calling databricks bundle deploy. It doesn't have to edit databricks.yml or commit an override file, and the environment variable beats both the target's mapping and the declared default.
| Order | Where the value comes from | Typical use |
|---|---|---|
| 1 | --var options on the bundle command | One-off override typed at the terminal |
| 2 | Environment variables beginning with BUNDLE_VAR_ | CI runners setting a per-run value without touching files |
| 3 | The variable-overrides.json file, if it exists | Local overrides kept outside the main YAML |
| 4 | The variables mapping inside the selected target | Fixed per-environment values, such as prod_catalog in prod |
| 5 | The default in the top-level variables definition | Fallback when nothing else sets the variable |
Checkpoint 4 of 9· Check yourself
A team wants one bundle variable, referenced as ${var.job_cluster}, to hold a full cluster definition with node type, worker count and Spark config, and to change it per target. How must the variable be declared?
Bundle variables are strings unless you set type: complex, and complex is the only valid value for type. A variable can hold a structure such as a cluster definition only with that setting.
“The only valid value is "complex" if the variable is a complex variable, otherwise do not define this key.”Source: docs.databricks.com
Checkpoint 5 of 9· Exam question
A bundle defines:
variables:
warehouse_id:
description: SQL warehouse used by the nightly job
default: abc123
and a job task references ${var.warehouse_id}. A CI pipeline needs to deploy to a staging target using a different warehouse ID on every run, without editing databricks.yml or committing a target-specific override file. Which approach satisfies this requirement?
Correct answer: A — Export an environment variable named BUNDLE_VAR_warehouse_id set to the desired ID before invoking databricks bundle deploy, since CLI variable resolution checks that environment prefix ahead of the declared default.
- A. The
BUNDLE_VAR_<name>environment variable convention is read by the CLI ahead of a variable's declared default, so exporting it per CI run supplies a fresh warehouse ID each time without touching any committed file. - B. A
lookupblock resolves an object's ID by looking it up by name in the workspace; it solves a different problem than supplying a caller-chosen literal value per run and would not let CI inject an arbitrary ID. - C. The
--profileflag selects a named Databricks CLI authentication profile; it does not accept key-value pairs for overriding bundle variables, so this would not affectwarehouse_idat all. - D. A committed overrides file is lower precedence than an environment variable in the CLI's resolution order, and it would also require a file edit and commit on every run, which the requirement explicitly rules out.
Sources5
4.Development mode, production mode and presets
**Setting mode on a target applies a group of common behaviours in one line.** Modes are optional, and a target with no mode deploys exactly what its configuration says. The two modes protect against opposite risks. Development mode keeps several engineers' copies from colliding and stops test jobs from firing on their own. Production mode refuses deployments that look like they came from the wrong place.
A target with mode: development does the following on deploy:
- Prefixes every resource that is not a file or notebook with
[dev ${workspace.current_user.short_name}], and tags each job and pipeline with adevtag - Marks every deployed Lakeflow pipeline
development: true - Pauses all schedules and triggers, so a nightly job does not start running from someone's laptop
- Allows concurrent runs on all jobs, so test runs can overlap
- Disables the deployment lock to speed up iteration
- Accepts
--cluster-id(or acluster_idmapping) to replace every cluster definition with one interactive cluster
A target with mode: production checks the deployment instead of relaxing it:
- Checks that every deployed Lakeflow pipeline is
development: false - Checks that the current Git branch matches the target's
git.branch, if one is set.--forceoverrides this check - Refuses cluster overrides, so the clusters defined in configuration are the ones that run
- If no service principal is used, checks that paths such as
root_pathare not overridden to a specific user, and thatrun_asandpermissionsare set
Databricks recommends a service principal as the run_as identity for production. Production mode encourages this through the checks above but doesn't strictly require it.
| Behaviour | development | production |
|---|---|---|
| [dev <short_name>] name prefix | Applied | Not applied |
| Pipelines' development flag | Set to true | Validated as false |
| Schedules and triggers | Paused | Left as configured |
| Git branch must match target | No check | Validated (override with --force) |
| --cluster-id override | Allowed | Not allowed |
| Deployment lock | Disabled | Enabled |
Presets let you adjust individual mode behaviours. Settings follow a three-level order: presets override the mode's defaults, and a setting on an individual resource overrides the preset. Suppose a job sets max_concurrent_runs: 10 and the jobs_max_concurrent_runs preset is 20. The job gets 10. Likewise, a schedule explicitly set to UNPAUSED stays unpaused even under a trigger_pause_status: PAUSED preset.
targets:
dev:
presets:
name_prefix: 'testing_' # prefix all resource names with testing_
pipelines_development: true # set development to true for pipelines
trigger_pause_status: PAUSED # set pause_status to PAUSED for all triggers and schedules
jobs_max_concurrent_runs: 10 # set max_concurrent runs to 10 for all jobs
tags:
department: financeCheckpoint 6 of 9· Match them up
Match each target setting to what it does when you run databricks bundle deploy.
Tap a term, then the definition that fits it.
Development mode relaxes settings for safe iteration, and production mode validates the deployment. Presets sit above the mode's defaults, and an explicit resource setting sits above the presets.
“presets override the default mode behavior, and settings of individual resources override the presets”Source: docs.databricks.com
Checkpoint 7 of 9· Exam question
A data engineer deploys a bundle to a target configured with mode: development and no presets overrides. Reviewing the deployed workspace objects afterward, which behaviors should the engineer expect to see applied automatically? (Select all that apply.)(Select 3)
Correct answers: A, B, C — Deployed job and pipeline names are prefixed with a [dev <username>] tag derived from the current user's short name.; Any schedules or triggers attached to deployed jobs and pipelines are paused so they do not fire unexpectedly during iteration.; Jobs deployed to the target allow concurrent runs so the engineer can trigger multiple test executions without waiting for a prior run to finish.
- A. Development mode's default name-prefixing behavior prepends a
[dev <short_name>]tag to resource names, which is exactly how deployed jobs and pipelines end up visibly scoped to the deploying user during iteration. - B. Pausing schedules and triggers is a documented development-mode default, preventing a job or pipeline the engineer is still editing from firing on its production schedule while it is redeployed repeatedly.
- C. Development mode also enables concurrent runs on deployed jobs by default, which lets an engineer kick off a new test run without waiting for an earlier iteration's run to finish first.
- D. Enforcing that the local branch match a target's configured branch is a production-mode validation, not a development-mode default; development targets are meant to tolerate branch-switching during iteration.
- E. Development mode does the opposite: it marks Lakeflow pipeline resources with
development: trueso pipeline runs use development-friendly behavior rather than mirroring the production execution path. - F. Requiring a service principal identity is a production-mode recommendation enforced through validation, not something development mode imposes; development targets commonly run as the deploying individual user.
Sources6
5.Validate, deploy, run, destroy, and what a deploy actually changes
A bundle goes through four commands, each taking -t to choose the target:
databricks bundle validatechecks the configuration and prints a summary of the bundle name, target and workspace. It warns about unknown resource properties, so a mistyped field shows up here rather than being silently ignored.databricks bundle deployuploads files and builds artifacts, then creates or updates the target's resources.databricks bundle run <key>starts a deployed job or pipeline, identified by its resource key from the YAML rather than its display name.databricks bundle destroypermanently deletes the jobs, pipelines and artifacts the bundle previously deployed. This cannot be undone.
A deployment matches resources by ID, not by name. The bundle stores the IDs of the resources it created as state in the workspace file system. On each deploy, a resource in the configuration that does not yet exist is created, one that exists is updated, and one removed from the configuration is deleted from the workspace if this bundle deployed it. Changing a job's name field therefore updates the same job, and deleting a job's YAML block deletes the job on the next deploy. To bring a job created in the UI under bundle control without recreating it, use databricks bundle deployment bind with the job's ID.
**root_path determines a deployment's identity.** It defaults to ~/.bundle/${bundle.name}/${bundle.target}, which combines the deployer, the bundle name and the target. Two engineers who deploy the same bundle to dev therefore get separate copies. Two different bundles that share a name and target, deployed by the same identity, will interfere with each other. A bundle only forgets a resource if you change the bundle name, the target or the workspace.
Use --force-lock. It takes the lock even though another deployment appears to hold it, which is safe only when the earlier deployment crashed or was interrupted and left a stale lock file. Adding it to every run switches off the protection that stops two real deployments from interfering with each other.
Other deploy flags: --fail-on-active-runs aborts if jobs or pipelines in the deployment are running. --auto-approve skips interactive prompts, which non-interactive CI needs. --select my_job deploys only the named resources and their upstream dependencies. That is handy in a dev workspace, but downstream resources are not updated, which is why it is not meant for production.
Checkpoint 8 of 9· Match them up
A team changes the YAML of a bundle that is already deployed and runs databricks bundle deploy -t dev again. Pair each change with what happens in the workspace.
Tap a term, then the definition that fits it.
The bundle keeps the IDs of the resources it created as state and matches on those IDs, not on display names. A rename therefore updates the same job, and a removed block deletes it. Changing the bundle name, target or workspace changes root_path, so the bundle forgets its earlier resources.
“Resource names are not used to correlate between a bundle deployment and a resource instance”Source: docs.databricks.com
6.Declaring libraries and environments in bundle resources
Notebook %pip, compute libraries and serverless environment dependencies each install packages at a different scope, as covered in library installation scopes (notebook %pip, compute/task libraries, environment dependencies). In a bundle, you declare those dependencies in the job or pipeline resource definition. Every deploy then writes the same library list into the workspace resource, so every run installs the same set without relying on someone attaching packages by hand.
Bundles support three kinds of library dependency:
- Python wheel files
- JAR files for Java or Scala
- PyPI, Maven or CRAN packages
For Python, you can also list dependencies in a pyproject.toml included in the bundle. To attach a wheel to a job task, add a libraries list to the task with one whl entry per wheel. The wheel can come from workspace files, a Unity Catalog volume, cloud object storage or a local path. A local wheel is built and uploaded as part of the deploy. Whether a particular library works still depends on the cluster configuration and where the library comes from.
Serverless jobs declare dependencies through an environment, not a cluster. A bundle job on serverless compute can either omit the cluster settings for a notebook task or reference an environment that holds the job's dependencies. Changing a library version is then a one-line change in the YAML: it is reviewed like code, deployed per target, and rolled back by reverting the commit.
Checkpoint 9 of 9· Check yourself
An engineer changes the wheel version in the libraries list of a job task in the top-level resources and runs databricks bundle deploy -t staging. The job is already deployed to both staging and prod. What happens?
Libraries are part of the job resource, so the deploy writes the new library list into the staging job it already tracks by ID and updates that job in place. Each target changes only when you deploy to it, so prod keeps the old version until a deploy with -t prod.
“If a resource in the bundle configuration exists in the target workspace, it is updated in the workspace.”Source: docs.databricks.com
Practise it for real
Take a template bundle through its full lifecycle on a development target and watch what development mode changes in the workspace.
1.Run databricks bundle init and choose the default Python template, then open the generated databricks.yml.
Why: The template produces a working databricks.yml with resources and targets to change.
You should see: A project folder with databricks.yml at its root, a job definition and a notebook.
2.Run databricks bundle validate.
Why: Validation catches configuration mistakes before anything reaches the workspace.
You should see: A summary of the bundle name, target and workspace, with warnings for any unknown resource property.
3.Run databricks bundle deploy -t dev against a target set to mode: development.
Why: This shows what development mode does to deployed objects.
You should see: The job appears in the workspace with a [dev] prefix followed by your short name, and any schedule paused.
4.Run databricks bundle run -t dev with the job's resource key.
Why: Runs are started by the resource key from the YAML, not the display name.
You should see: A run of the deployed job starts in the dev workspace.
5.Run databricks bundle destroy -t dev.
Why: This removes everything the deployment created.
You should see: The previously deployed job and its artifacts are permanently deleted.
Stuck? Get a nudge
If deploy reports a held lock after an interrupted attempt, --force-lock is only for that stale-lock situation.
Sources
(9)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“A bundle must contain one (and only one) configuration file named databricks.yml at the root of the bundle project folder.”
↩︎ What a bundle is and where its configuration lives“Notice that you do not need to declare the notebook_task mapping within the prod mapping”
↩︎ Targets: one bundle, several environments“Databricks recommends that you use the host mapping instead of the default mapping wherever possible”
↩︎ Targets: one bundle, several environments“it falls back to use the notebook_task mapping within the top-level resources mapping, if the notebook_task mapping is not explicitly overridden within the prod mapping”
↩︎ Checkpoint“The only valid value is "complex" if the variable is a complex variable, otherwise do not define this key.”
↩︎ Checkpoint - 2.https://docs.databricks.com/aws/en/dev-tools/bundlesOfficial docs
“Declarative Automation Bundles are an infrastructure-as-code (IaC) approach to managing your Databricks projects.”
↩︎ What a bundle is and where its configuration lives“Your bundle project's collection of source files and metadata is deployed as a single bundle to your target environment.”
↩︎ Key concept - 3.
“The REST API object's supported create request fields, expressed as YAML, are the resource's supported keys.”
↩︎ What a bundle is and where its configuration lives“The databricks bundle validate command returns warnings if unknown resource properties are found in bundle configuration files.”
↩︎ Validate, deploy, run, destroy, and what a deploy actually changes - 4.
“specify a configuration profile using the --profile (or -p) flag”
↩︎ Targets: one bundle, several environments“If a resource is removed from the bundle configuration, it is removed from the target workspace if it was previously deployed.”
↩︎ Validate, deploy, run, destroy, and what a deploy actually changes“It should only be used if the previous deployment crashed or was interrupted and left a stale lock file.”
↩︎ Validate, deploy, run, destroy, and what a deploy actually changes“It is not intended for use in production.”
↩︎ Validate, deploy, run, destroy, and what a deploy actually changes“If no command options are specified, the default target as declared within the bundle configuration files is used.”
↩︎ Exam trap 1“Resource names are not used to correlate between a bundle deployment and a resource instance”
↩︎ Exam trap 4“If no command options are specified, the default target as declared within the bundle configuration files is used.”
↩︎ Prediction“Resource names are not used to correlate between a bundle deployment and a resource instance”
↩︎ Checkpoint“If a resource in the bundle configuration exists in the target workspace, it is updated in the workspace.”
↩︎ Checkpoint - 5.
“Within any environment variables set that begin with BUNDLE_VAR_.”
↩︎ Custom variables and how the CLI resolves them“use the same approach during both the deployment and run stages.”
↩︎ Custom variables and how the CLI resolves them“The only valid value for the type setting is complex.”
↩︎ Custom variables and how the CLI resolves them“The Databricks CLI looks for values for variables in the following order, stopping when it finds a value for a variable:”
↩︎ Exam trap 2 - 6.
“Pauses all schedules and triggers on deployed resources such as jobs or quality monitors.”
↩︎ Development mode, production mode and presets“Validates that all related deployed Lakeflow pipelines are marked as development: false.”
↩︎ Development mode, production mode and presets“presets override the default mode behavior, and settings of individual resources override the presets.”
↩︎ Development mode, production mode and presets“Validates that the current Git branch is equal to the Git branch that is specified in the target.”
↩︎ Exam trap 3“presets override the default mode behavior, and settings of individual resources override the presets”
↩︎ Checkpoint - 7.
“Destroying a bundle permanently deletes a bundle's previously-deployed jobs, pipelines, and artifacts. This action can't be undone.”
↩︎ Validate, deploy, run, destroy, and what a deploy actually changes - 8.
“To add a Python wheel file to a job task, in libraries specify a whl mapping for each library to be installed.”
↩︎ Declaring libraries and environments in bundle resources“Library dependencies are declared in your bundle configuration files.”
↩︎ Declaring libraries and environments in bundle resources - 9.
“or you can specify an environment”
↩︎ Declaring libraries and environments in bundle resources