Skip to content

Database Instance fails when incrementally deploying using bundle deploy #4123

@miguelandreu

Description

@miguelandreu

Describe the issue

When a databricks.yml file has a database instance and a database catalog referenciated and you try to perform a deployment on an already asset bundle deployed, bundle terraform fails because name is already deployed.
It is creating that, when you have a single bundle for an app with database, everytime you try to deploy new features, an error will appear unless you change the database_instance name

Configuration

databricks.yml

resources:
  database_instances:
    marketplace_instance:
      name: ${var.instance_name}
      capacity: ${var.capacity}
  database_catalogs:
    marketplace_catalog:
      database_instance_name: ${resources.database_instances.marketplace_instance.name}
      name: ${var.catalog_name}
      database_name: ${var.database_name}
      create_database_if_not_exists: true
  apps:
    marketplace_app:
      name: ${var.app_name}
      description: "Astellas Internal Data Marketplace - Discover, explore, and manage data products"
      source_code_path: ${workspace.file_path}/src
      resources:
        - name: "marketplace_database"
          database:
            database_name: ${resources.database_catalogs.marketplace_catalog.database_name}
            instance_name: ${resources.database_instances.marketplace_instance.name}
            permission: "CAN_CONNECT_AND_CREATE"

Steps to reproduce the behavior

Initial deploy

  1. Create a bundle project with an app and a database
  2. databricks bundle validate -> success
  3. databricks bundle deploy -> database and app are deployed

New feature development that needs to be deployed

  1. databricks bundle validate -> success
  2. databricks bundle deploy -> error
Error: terraform apply: exit status 1

Error: failed to create database_instance

  with databricks_database_instance.marketplace_instance,  on bundle.tf.json line 44, in resource.databricks_database_instance.marketplace_instance:  44:       }

Instance name is not unique.

Expected Behavior

You can bypass the creation of a database_instance if it is already existing.
If fails, deployment is rolled back

Actual Behavior

Code is deployed because step is done before the attempt of the creation of the database instance

OS and CLI version

databricks CLI v0.273.0
Python 3.12.10
Windows 11 Enterprise 10.0.26100 Build 26100

Is this a regression?

No

Debug Logs

Attached

debug_database_instance.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingDABsDABs related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions