Sub topic 3
Extending a Databricks Asset Bundle
Assume you know YAML, Git, and basic Databricks jobs. A bundle can also manage project structure, identities, build artifacts, and deployment cleanup.
Start from a template
Use bundle init to scaffold a project instead of creating every file manually. Choose a template that matches your language and workload, then review its generated databricks.yml and resource files.
databricks bundle init
databricks bundle validate -t devTemplates provide a starting point, not a production design. Replace placeholder workspace URLs, node types, and identities before deployment.
Split configuration into files
Keep databricks.yml focused on shared settings. Use include to load jobs, pipelines, permissions, and artifacts from separate files.
include:
- resources/*.yml
- resources/**/*.ymlPaths are resolved relative to the bundle configuration. Use predictable names such as resources/daily_etl.yml and keep related definitions together. This makes reviews smaller and reduces merge conflicts.
Configure production identity
Development deployments often use your user identity. Production jobs should usually run as a service principal, which is a non-human identity managed by your organization.
targets:
prod:
mode: production
workspace:
host: https://<prod-workspace-url>
run_as:
service_principal_name: <service-principal-application-id>Grant the service principal only the workspace, catalog, storage, and job permissions it needs. Check that the deployment identity can create or update resources before the pipeline runs.
> callout note > run_as controls who runs the deployed workload. It does not automatically grant that identity access to every data source. > ```
Build and deploy artifacts
For Python libraries, define an artifact that runs a build command, then reference the resulting wheel from a job. Build in a clean environment so the deployed file is reproducible.
artifacts:
etl_wheel:
type: whl
build: poetry buildThe bundle uploads the artifact during deployment. Keep dependency locking and artifact testing in version control.
State, cleanup, and CI/CD
The CLI tracks deployment state so it can update the resources belonging to a target. Destroy a temporary target when it is no longer needed:
databricks bundle destroy -t devReview the destroy plan carefully. Production cleanup should require explicit approval.
A CI/CD pipeline can authenticate with a service-principal credential, validate the bundle, deploy to development, run tests, and promote the same commit to production.
Exercise
Why should a production job use a service principal instead of a developer's identity?
Show answer
A service principal provides a stable, auditable identity that does not depend on an employee's account or session.