Pulumi Databricks Provider

1.90.0 · active · verified Thu Apr 16

The `pulumi-databricks` Python package is an Infrastructure as Code (IaC) tool that enables developers to define, deploy, and manage Databricks cloud resources programmatically. It wraps the Databricks Terraform provider, providing Pythonic access to resources such as notebooks, clusters, jobs, and Unity Catalog entities. The library is actively maintained with frequent updates, typically released multiple times per month, reflecting the rapid development of its upstream Terraform provider. The current version is 1.90.0.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart program demonstrates how to configure the Pulumi Databricks provider and create a simple Databricks Notebook. It assumes Databricks authentication is handled via environment variables `DATABRICKS_HOST` and `DATABRICKS_TOKEN`. The example retrieves the current user's home directory to place the notebook, showcasing a common pattern for dynamic resource naming.

import pulumi
import pulumi_databricks as databricks
import os

# Configure Databricks authentication using environment variables
# DATABRICKS_HOST and DATABRICKS_TOKEN are typically set.
# Example: export DATABRICKS_HOST="https://adb-YOUR_WORKSPACE_ID.1.azuredatabricks.net"
#          export DATABRICKS_TOKEN="dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

# Retrieve current user information (useful for creating resources in user's home directory)
current_user = databricks.get_current_user()

# Create a Databricks Notebook
hello_notebook = databricks.Notebook(
    "my-first-notebook",
    path=current_user.then(lambda user: f"{user.home}/pulumi_hello_world_notebook"),
    language="PYTHON",
    content_base64="# Databricks notebook created by Pulumi\nprint('Hello from Pulumi!')\n",
    # Note: content_base64 is discouraged for large notebooks; consider 'source' argument instead.
    # For real applications, you would typically load content from a file using base64.b64encode(open('path/to/notebook.py', 'rb').read()).decode('utf-8')
)

pulumi.export("notebook_url", hello_notebook.url)

view raw JSON →