CertSafari
    Databricks Certified Data Engineer Professional - October 9 onwards· Lessons

    Domain 1 · Lesson 1/45

    Structuring a Declarative Automation Bundle project

    Implement scalable Python project structures for Declarative Automation Bundles (formerly Databricks Asset Bundles / DABs) to support modular development and CI/CD integration.

    14 min read
    1.92% of exam
    6 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Lay out a bundle repository with databricks.yml, resources/, src/ and tests/ so that jobs, pipelines and tests share one code base
    • Split resource definitions into separate YAML files and wire them into one deployment with the include mapping
    • Load resources defined in Python alongside YAML through the python section of databricks.yml
    • Configure dev and prod targets with deployment modes and a service-principal run_as identity for unattended CI/CD deployment

    Key concept

    databricks.yml as the single bundle root — Every bundle has exactly one databricks.yml at the top of the project folder. Every other configuration file, whether resource YAML or Python resource loaders, only becomes part of the deployment because databricks.yml points to it.

    1.What a bundle project contains

    A Declarative Automation Bundle (formerly Databricks Asset Bundle) is an infrastructure-as-code project. It holds your business logic and the definitions of the Databricks resources that run it, and both live in source control. The whole folder is deployed as one unit to a target environment. Because of that, the project's structure decides what reaches a workspace together, and what a CI/CD pipeline can validate in a single step.

    A bundle bundles four kinds of content:

    • cloud infrastructure and workspace configuration
    • source files such as notebooks and Python files holding the business logic
    • definitions and settings for resources such as Lakeflow Jobs, Lakeflow pipelines, dashboards and MLflow experiments
    • unit tests and integration tests

    The default-python template from databricks bundle init shows the conventional layout. Configuration and code sit in separate folders. databricks.yml at the root names the bundle, references the other configuration files, holds the wheel build settings and catalog/schema variables, and defines the targets. Each resource gets its own file under resources/, such as resources/sample_job.job.yml. The importable Python package lives under src/, and a pyproject.toml describes how to build it. Tests sit in tests/. A job task, a pipeline and a pytest suite can all import the same package from src/, so a transformation is written once and exercised everywhere. Writing those tests is covered in unit and integration testing.

    Files generated by the default-python template and what each one is for
    PathRole in the project
    databricks.ymlBundle name, references to other files, whl build settings, catalog and schema variables, target settings
    resources/sample_job.job.ymlSettings for one job resource
    src/Files the Python wheel job uses to build the Python wheel file
    tests/Sample unit tests
    README.mdGetting-started notes for the bundle

    Teams that start many projects can make this layout a standard. A custom bundle template can bake in default permissions, service principals and CI/CD configuration, so each new repository begins with the same structure instead of a hand-copied one.

    Checkpoint 1 of 7· Match them up

    In a project generated by the default-python template, match each path to its role in the bundle.

    Tap a term, then the definition that fits it.

    Sources12

    2.Splitting resource definitions with include

    The include mapping is how separate configuration files join the deployment. databricks.yml is the main file, but it can list other files or path globs under include. The CLI reads every file that matches and combines them into one bundle configuration. A project with a pipeline and two jobs can therefore keep each definition in its own file under resources/ and add one glob such as resources/*.yml. All three stay active in every deploy.

    databricks.yml pulling in every YAML file that matches a globyaml
    # databricks.yml
    
    bundle:
      name: hello-bundle
    
    include:
      - '*.yml'

    An included file can carry any top-level mapping, not only resources. In the same example, hello-job.yml holds the job and a separate targets.yml holds the dev and prod targets. That split is useful when several people edit different jobs: each change touches one small file, and a reviewer sees just that resource in the diff.

    Checkpoint 2 of 7· Check yourself

    A team moves its pipeline and two job definitions out of databricks.yml into separate files under resources/. After the next deploy, none of the three resources is created or updated. What change to databricks.yml fixes this?

    Checkpoint 3 of 7· Exam question

    A team maintains a Declarative Automation Bundle for a Lakeflow pipeline and two Lakeflow Jobs. As the project grows, they want to define each job and pipeline in its own YAML file under a resources/ folder while keeping every definition active in one bundle deployment. Which approach correctly wires these separate resource files into databricks.yml?

    Sources3

    3.Defining resources in Python

    Resources can also be written as Python code, and they can sit alongside YAML resources in the same bundle. This needs Databricks CLI 0.275.0 or above. The pydabs template sets it up, and in an existing bundle you add a python section to databricks.yml. That section names a virtual environment, which must have the databricks-bundles package installed, and one or more loader functions.

    The python section that tells the CLI where to find Python-defined resourcesyaml
    python:
      # Activate the virtual environment before loading resources defined in
      # Python. If disabled, it defaults to using the Python interpreter
      # available in the current shell.
      venv_path: .venv
      # Functions called to load resources defined in Python.
      # See resources/__init__.py
      resources:
        - 'resources:load_resources'

    The resources folder has to be a package, so it needs an __init__.py. By default that file defines load_resources, which calls load_resources_from_current_package_module() to pick up every Python file in the package. The CLI calls this function at deploy time only and never at run time. That makes it a good place to generate resources from metadata: the documented example loops over ["US", "NL"] and calls resources.add_resource once per country, so adding a market means editing a list rather than copying a job definition. Jobs are built with Job.from_dict, which takes the same dictionary shape as YAML, or with dataclasses such as Job, Task and NotebookTask.

    Choose Python definitions when resources follow a pattern you would otherwise copy and paste. Keep YAML for one-off resources, where a flat file is easier to review.

    Checkpoint 4 of 7· Fill the gap

    An existing YAML bundle is getting resources defined in Python. Which top-level key in databricks.yml makes the CLI load them?

     ? :
      # Activate the virtual environment before loading resources defined in
      # Python. If disabled, it defaults to using the Python interpreter
      # available in the current shell.
      venv_path: .venv
      # Functions called to load resources defined in Python.
      # See resources/__init__.py
      resources:
        - 'resources:load_resources'

    Sources4

    4.Targets, deployment modes and run identity

    The targets mapping lets one bundle deploy to several environments. Anything defined at the top level applies to every target. A target overrides only the fields it lists, and everything else falls back to the top-level definition. In the example below, prod changes the workspace host and the cluster ID but keeps the job's notebook_task from the top-level resource.

    A prod target that overrides the host and the cluster but inherits the rest of the jobyaml
    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

    Only one target can be marked default: true, and it is the target used when a command names none. Putting it on dev is the safe choice: a developer who forgets the flag deploys to their own sandbox. Reaching production then always takes a deliberate -t prod. For the workspace itself, set the host mapping on each target. The CLI then finds the matching profile in .databrickscfg, which keeps the configuration portable.

    Deployment modes are optional. Each one applies a group of commonly used settings to a target, and you choose it with mode: development or mode: production. Development mode suits each engineer's own copy. Production mode adds the checks that an unattended CI/CD deployment should not skip.

    What each deployment mode does when the target is deployed
    Behaviourmode: developmentmode: production
    Resource namesPrefixed with [dev ${workspace.current_user.short_name}] and tagged devNot prefixed (a name_prefix preset can be added)
    Lakeflow pipelinesMarked development: trueValidated to be development: false
    Concurrency and lockingConcurrent job runs enabled; deployment lock disabledValidates the current Git branch matches the target's git branch (override with --force)
    IdentityRuns as the deploying userService principals recommended; enforce by setting run_as to one

    The [dev username] prefix is what keeps developers from colliding in a shared workspace. Putting development mode on a prod target would therefore stamp one person's name on production jobs and mark production pipelines as development pipelines.

    run_as sets the identity that deployed jobs execute under, and you can set it per target. For production the right value is a service principal, given by its application ID in service_principal_name. With that in place, scheduled jobs no longer run as whichever developer or pipeline happened to deploy last. The permission to run the production workflow is separate from the identity that deployed the bundle. If a production-mode deploy fails because no run_as identity is set, the direct fix is a run_as block with service_principal_name under the prod target. A permissions block will not fix it. Permissions say who can access or manage the resources, while run_as says who the workloads run as. Deleting the mode key would also make the error go away, but only by removing the production checks. The deploy and run commands themselves are covered in deploying bundles.

    run_as in the top-level specification: a user or a service principalyaml
    # This is the identity to use to run the bundle
    run_as:
      - user_name: <user-name>
      - service_principal_name: <service-principal-name>

    Checkpoint 5 of 7· Check yourself

    Scheduled production jobs from a bundle keep running as whichever engineer or pipeline deployed them last. The team wants them to execute as the service principal sp-prod-etl instead. Which change to the prod target does this?

    Checkpoint 6 of 7· Exam question

    An engineer is configuring dev and prod targets in a single databricks.yml so the same bundle can be validated by individual developers and deployed unattended by a CI/CD pipeline into a shared production workspace. Which two configuration choices are appropriate for the prod target specifically? (Choose 2.)(Select 2)

    0 of 2 selected

    Checkpoint 7 of 7· Exam question

    A CI/CD pipeline runs databricks bundle deploy --target prod against the prod target, which has mode: production set. The deploy fails with an error stating that a run_as identity must be specified for the target. What is the most direct fix that keeps the production deployment unattended and reproducible?

    Sources356

    Sources

    (6)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Your bundle project's collection of source files and metadata is deployed as a single bundle to your target environment.”
      ↩︎ What a bundle project contains
      “A custom template might include default permissions, service principals, and custom CI/CD configuration.”
      ↩︎ What a bundle project contains
    2. 2.
      “This file specifies the bundle's name, includes references to the bundle's files, specifies whl build settings, defines catalog and schema variables”
      ↩︎ What a bundle project contains
      “databricks.yml: This file specifies the bundle's name, includes references to the bundle's files, specifies whl build settings, defines catalog and schema variables”
      ↩︎ Checkpoint
    3. 3.
      “For more modularization and better reuse of definitions and settings across bundles, split your bundle configuration into separate files:”
      ↩︎ Splitting resource definitions with include
      “it falls back to use the notebook_task mapping within the top-level resources mapping”
      ↩︎ Targets, deployment modes and run identity
      “Databricks recommends that you use the host mapping instead of the default mapping wherever possible, as this makes your bundle configuration files more portable.”
      ↩︎ Targets, deployment modes and run identity
      “A bundle must contain one (and only one) configuration file named databricks.yml at the root of the bundle project folder.”
      ↩︎ Key concept
      “but it can reference other configuration files, such as resource configuration files, in the include mapping”
      ↩︎ Exam trap 1
      “it can reference other configuration files, such as resource configuration files, in the include mapping.”
      ↩︎ Checkpoint
      “You must specify "-t prod", because the "dev" target”
      ↩︎ Prediction
      “This is the identity to use to run the bundle”
      ↩︎ Checkpoint
    4. 4.
      “Define resources in Python code. These definitions can coexist with resources defined in YAML.”
      ↩︎ Defining resources in Python
      “The specified virtual environment must contain the installed databricks-bundles PyPi package.”
      ↩︎ Defining resources in Python
      “You can use Python to create resources programmatically. For example, you can load configuration files and create jobs in a loop:”
      ↩︎ Defining resources in Python
    5. 5.
      “Deployment modes are optional. You can deploy bundles without setting a mode or configuring presets.”
      ↩︎ Targets, deployment modes and run identity
      “Databricks recommends that you use service principals for production deployments. You can enforce this by setting run_as to a service principal.”
      ↩︎ Targets, deployment modes and run identity
      “Prepends all resources that are not deployed as files or notebooks with the prefix [dev ${workspace.current_user.short_name}]”
      ↩︎ Exam trap 2
    6. 6.
      “setting a run_as identity to a service principal for production targets is the most secure way of running a production workflow”
      ↩︎ Targets, deployment modes and run identity
      “Decouples the permission to run the production workflow from the identity that created or deployed the bundle.”
      ↩︎ Exam trap 3

    Continue to part 2 of 2

    Building Python wheels as bundle artifacts

    Spotted a mistake, or was something unclear? Tell us.