This file provides guidance to LLM-based agents when working with code in this repository.
make build- Build the provider binarymake install- Build and install the provider locally for Terraform developmentmake test- Run unit tests with lintingmake lint- Run linting with staticcheck (always use this instead of running staticcheck directly)
make fmt- Format Go code with goimports and gofmtmake fmt-docs- Format code samples in documentation (requires terrafmt)make ws- Validate whitespace in files
make vendor- Populate vendor directory with dependenciesmake schema- Print provider schemamake diff-schema- Compare current schema with previous version (useful for migration verification)
For unit tests:
go test -v -run TestSpecificTest ./path/to/packageFor integration tests:
- First, load the environment to use from
~/.databricks/debug-env.json. The keys in this file are environments, and the values are maps of environment variable names to values. Based on the *Level test function used, load the appropriate environment:- WorkspaceLevel: "workspace"
- AccountLevel: "account"
- UnityWorkspaceLevel: "ucws"
- UnityAccountLevel: "ucacct"
- Then, run the test.
go test -v -run TestAccResourceName ./path/to/package
This codebase implements two Terraform provider architectures that are muxed together:
- SDKv2 Provider: Legacy implementation in root directories (e.g.,
catalog/,clusters/,jobs/) - Plugin Framework Provider: New implementation in
internal/providers/pluginfw/products/
providers.go- Main provider muxing logic combining SDKv2 and Plugin Frameworksdkv2/- SDKv2-specific provider implementationpluginfw/- Plugin Framework provider implementation with auto-generated schemascommon/- Shared utilities between both providers
Auto-generated Go structs from Databricks SDK:
*_tf/model.go- Current Plugin Framework compatible structs*_tf/legacy_model.go- SDKv2 compatible structs with_SdkV2suffix
- Root directories (e.g.,
catalog/,jobs/,clusters/): SDKv2 resources and data sources internal/providers/pluginfw/products/: Plugin Framework resources organized by service
Resources are being migrated from SDKv2 to Plugin Framework. When migrating:
- Use
_SdkV2suffixed structs frominternal/service/for schema compatibility - Call
cs.ConfigureAsSdkV2Compatible()in schema definition - Ensure no schema breaking changes with
make diff-schema
- Create resource file in appropriate root directory (e.g.,
catalog/resource_new_thing.go) - Use
common.Resource{}helper with auto-generated schema from struct tags - Add to provider in
providers/sdkv2/sdkv2.go
- Create in
internal/providers/pluginfw/products/{service}/ - Use
ResourceStructToSchema()with structs frominternal/service/{service}_tf/ - Implement required interfaces (
ResourceWithConfigure, etc.) - Add to
internal/providers/pluginfw/pluginfw.go
common.DatabricksClient- Core client wrapper- Access workspace client via
client.GetWorkspaceClientForUnifiedProvider() - Access account client via
client.GetAccountClient() - Always use
c.WorkspaceClientUnifiedProvider()instead ofc.WorkspaceClient()when contributing new or modified resources. - Client automatically handles authentication and retries
- Unit tests:
*_test.gofiles usingqa.ResourceFixturefor HTTP mocking - Integration tests:
*_acc_test.gofiles with live API testing - Test naming conventions determine environment:
TestAcc*- Workspace-level tests across all cloudsTestMwsAcc*- Account-level tests across all cloudsTestUcAcc*- Unity Catalog tests across all clouds
The exporter (exporter/ directory) generates Terraform configuration (.tf files) and import scripts from existing Databricks resources.
When working on exporter code, read exporter/AGENTS.md for additional instructions.
Some Unity Catalog resources (e.g., storage credentials, external locations) work with both account-level and workspace-level providers but require different ID formats for imports:
ID Parsing Pattern: Implement a parse{ResourceName}Id() function that:
- Splits composite IDs on "|" delimiter (format:
metastore_id|resource_name) - For account-level providers: extracts metastore_id, sets it in state, updates resource ID to simple name
- For workspace-level providers: uses the ID as-is (simple name)
- Returns parsed components and any validation errors
CRUD Method Consistency: All CRUD methods (Create, Read, Update, Delete) must use the same ID parsing logic to ensure consistent behavior across operations.
Testing Import Functionality: Use qa.ResourceFixture with:
Read: trueto test import behavior- Test both valid composite ID format and simple name format
- Test error conditions with exact error message matching
- Example:
"metastore123|my-credential"and"my-credential"
Documentation Pattern: When documenting import formats, specify "when using a workspace-level/account-level provider" to clarify it's about provider configuration, not resource classification.
- Files should not exceed 600 lines
- don't make changes in files that have
DO NOT EDITin the first line - Functions should fit on a 13" screen (max 40 lines, except tests)
- No unnecessary package exports (avoid public structs/types unless needed outside package)
- Use
qa.EnvironmentTemplate()instead of complexfmt.Sprintfwith >4 placeholders
For unit tests use the MockWorkspaceClientFunc from Databricks Go SDK instead of HTTPFixture.
Use ApplyAndExpectData where it's possible.
Order imports as: Go standard library, vendor packages, current provider packages. Within each section, maintain alphabetical order.
- All resources and data sources require Terraform Registry compatible documentation in
docs/ - Code samples must be formatted with
make fmt-docs - Cross-link integrity between markdown files is required
- Use Terraform Registry Doc Preview Tool for validation
All user-facing changes must be documented in NEXT_CHANGELOG.md with format:
* <Summary of change> ([#<PR number>](<PR link>)).
<Optional additional information>
When migrating resources to Plugin Framework, always run make diff-schema to ensure no breaking changes to the Terraform schema.
- Always run
make fmt lint wsbefore making any commit.