Skip to content

Commit e68b551

Browse files
authored
Add direct engine docs (#4054)
1 parent 7938040 commit e68b551

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/direct.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Status
2+
3+
Status: experimental, only recommended for development targets or evaluation, not for production use.
4+
Known issues: https://github.com/databricks/cli/issues?q=state%3Aopen%20label%3Aengine%2Fdirect
5+
6+
## Reporting bugs
7+
8+
Click "new issue" on [https://github.com/databricks/cli/issues](https://github.com/databricks/cli/issues) and select "Bug report for Databricks Asset Bundles with direct deployment engine".
9+
10+
Please ensure you are on the latest version of CLI when reporting an issue.
11+
12+
## Background
13+
14+
Databricks Asset Bundles were originally implemented on top of databricks-terraform-provider.
15+
Since version 0.279.0 DABs support two different deployment engines: "terraform" and "direct".
16+
The latter does not make use of Terraform.
17+
It is intended to be a drop-in replacement and will become the only engine we support in 2026\.
18+
19+
## Advantages
20+
21+
The new engine implements resources CRUD directly on top of SDK Go and provides the following benefits over the original one:
22+
23+
* Self-contained binary that does not require downloading Terraform and terraform-provider-databricks before deployment.
24+
* Avoid issues with firewalls/proxies/custom provider registries.
25+
* Explanation why a given action is planned and detailed diff of changes available in "bundle plan \-o json".
26+
* Faster deployment.
27+
* Simplified development of new resources, implement CRUD directly in CLI repo, no need to coordinate with terraform provider release.
28+
29+
## Disadvantages
30+
31+
There are known issues, see https://github.com/databricks/cli/issues?q=state%3Aopen%20label%3Aengine%2Fdirect
32+
33+
## Usage
34+
35+
### Migrating the existing deployment
36+
37+
The direct engine uses its own state file, also JSON, but with a different schema from terraform state file. In order to migrate an existing Terraform-based deployment, use the "bundle deployment migrate" command. The command reads IDs from the existing deployment.
38+
39+
The full sequence of operations:
40+
41+
1. Perform full deployment with Terraform: bundle deploy \-t my\_target
42+
2. Migrate state file locally: bundle deployment migrate \-t my\_target
43+
3. Verify that migration was successful: bundle plan should work and should not show any changes to be planned: bundle plan \-t my\_target
44+
4. If not satisfied with the result, remove new state file: rm .databricks/bundle/my\_target/resources.json
45+
5. If satisfied with the result, do a deployment to synchronize the state file to the workspace: bundle deploy \-t my\_target
46+
47+
### Using on new bundles
48+
49+
For bundles that were never deployed, the migrate command will not work. Instead, deploy with an environment variable set: DATABRICKS\_BUNDLE\_ENGINE=direct bundle deploy \-t my\_target.
50+
51+
## Differences from terraform
52+
53+
### Diff calculation
54+
55+
Unlike Terraform which maintains a single "resource state" (a mix of local configuration and remote state), the new engine keeps these separate and only records local configuration in its state file.
56+
57+
The diff calculation is done in 2 steps:
58+
59+
* Step 1: local changes: local config is compared to the snapshot of config used for the most recent deployment. The remote state plays no role there.
60+
* Step 2: remote changes: remote state is compared to the snapshot of config used for the most recent deployment.
61+
62+
The consequences of this are:
63+
64+
* Changes in databricks.yml resource configuration are never ignored and will always trigger an update.
65+
* Resource fields behaving "inconsistently" and not handled by the implementation do not trigger ["Provider produced inconsistent result after apply"](https://github.com/databricks/terraform-provider-databricks/issues?q=is%3Aissue%20%22Provider%20produced%20inconsistent%20result%20after%20apply%22) error. Such resources will be deployed successfully by direct engine. This can result in a drift: the deployed resources will be marked as "to be updated" during the next plan/deploy.
66+
67+
### $resources references lookup
68+
69+
Note, the most common use of $resources is resolving ID ($resources.jobs.foo.id) which should behave identically between terraform and direct engine. The differences can happen in other fields.
70+
71+
The resolution of $resources references in direct engine (e.g. $resources.pipelines.foo.name) is performed in two steps:
72+
73+
1. References pointing to fields that are present in the config ("local") are resolved during the plan phase to the value provided in the local config.
74+
2. References that are not present in the config, are resolved from remote state, that is state fetched via appropriate GET request for a given resource.
75+
76+
The schema that is used for $resource resolution is available in [acceptance/bundle/refschema/out.fields.txt](https://github.com/databricks/cli/blob/main/acceptance/bundle/refschema/out.fields.txt). The fields marked as "ALL" and "STATE" can be used for local resolution. The fields marked as "ALL" or "REMOTE" can be used for remote resolution.

0 commit comments

Comments
 (0)