How databricks/terraform-provider-databricks works
This project is the Databricks Terraform Provider—a Go-based Terraform plugin that enables users to provision and manage Databricks resources via Terraform. The provider implements a large set of resources and data sources (e.g., clusters, catalog, jobs, SQL endpoints, workspaces, etc.) and uses a modular, plugin-driven design.
Main Components
• Terraform Engine & Provider: Show Terraform as the orchestration engine that loads the Databricks provider plugin. Emphasize that the provider acts as a plugin that implements the Terraform Resource and Data Source interfaces.
• Provider Core: Illustrate the main “provider” binary (main.go and go.mod), which bootstraps the plugin.
• Resource & Data Modules: Group directories like catalog, clusters, access, dashboards, jobs, mlflow, mws, pipelines, and others under “Resources & Data Sources.” Indicate that each of these modules encapsulates the logic for managing a specific Databricks feature.
• Plugin Framework & Internal Providers: Represent the “internal/providers” and “internal/providers/pluginfw” directories as components that implement the extensible plugin framework. They handle tasks including auto-generation, attribute conversion, and mapping between Terraform schema and Databricks API models.
• Exporter Module: Mark the “exporter” component as an experimental sub-system (which provides an evolving interface to export or generate Terraform configurations from Databricks resources).
• Testing and CI/CD: Optionally include elements for integration and acceptance tests (directories like “internal/acceptance” and GitHub workflows). These illustrate how the project ensures quality and compliance via automation.
Depicting Relationships and Data Flow
• For each resource or data module, illustrate a flow that begins at the provider core, then delegated to the specific module (e.g., clusters, notebooks, etc.), and then outward through HTTP or API calls to the Databricks cloud.
• Bidirectional communication (request/response) with the external Databricks API.
• Internal plugin framework as a mediator that handles schema conversions, resource mapping, and, in some cases, automatic generation of resource code—pointing to the corresponding “internal/providers/pluginfw” modules.
Architectural Patterns & Design Principles
• Modularity: Emphasize that each functional domain (access, catalog, clusters, etc.) is separated into its own directory/module, making the system highly modular.
• Plugin Architecture: Show how the internal plugin framework provides extensibility. Each resource product (e.g., “app”, “cluster”, “mlflow”, “jobs”, etc.) is implemented as a separate plugin component that adheres to a common interface.
• Code Generation: Note the presence of the codegen components (e.g., .codegen.json, codegen directory) which help automate parts of the implementation.
• Test-Driven: Illustrate that there is a robust set of unit, integration, and acceptance tests to validate each component.