Sub topic 2
Targets: dev and prod from one bundle
Assume you know basic YAML, Git, Databricks jobs, and CLI commands. A target is a named deployment configuration. It lets one bundle use different workspaces, variables, and identities for development and production.
Define development and production targets
Put shared settings in databricks.yml. Each target overrides only what differs.
bundle:
name: my_project
variables:
catalog:
description: Unity Catalog catalog for job output
default: dev_catalog
node_type_id:
description: Cloud-specific job cluster node type
targets:
dev:
mode: development
default: true
workspace:
host: https://<your-dev-workspace-url>
variables:
node_type_id: <dev-node-type>
prod:
mode: production
workspace:
host: https://<your-prod-workspace-url>
root_path: /Workspace/Shared/.bundle/${bundle.name}/${bundle.target}
variables:
catalog: prod_catalog
node_type_id: <prod-node-type>
run_as:
service_principal_name: <service-principal-application-id>A development target usually deploys under your user identity and allows faster iteration. A production target should use a controlled workspace location and a service principal, which is an application identity managed separately from a person.
Variables and per-target overrides
A variable is a named value that resource definitions can substitute at deployment time. Keep environment-specific values such as catalogs, cluster types, and paths out of shared resource files.
For example, a job resource can use these variables:
resources:
jobs:
daily_etl:
name: daily_etl
tasks:
- task_key: ingest
notebook_task:
notebook_path: ../src/ingest.py
base_parameters:
catalog: ${var.catalog}The dev target uses the variable default unless it overrides it. The prod target changes catalog to prod_catalog. You can also override a value for one command with --var, but do not use that to hide important configuration from source control.
Validate, deploy, and run
Select a target with -t. Validate before deployment so the CLI can resolve configuration and report errors early.
databricks bundle validate -t dev
databricks bundle deploy -t dev
databricks bundle run -t dev daily_etl
databricks bundle validate -t prod
databricks bundle deploy -t prod
databricks bundle run -t prod daily_etlUse destroy carefully. It removes resources managed by that target.
Exercise
Which command validates the production target without deploying it?
Show answer
databricks bundle validate -t prod.