databricks / terraform-databricks-examples

Examples of using Terraform to deploy Databricks resources
https://registry.terraform.io/modules/databricks/examples/databricks/latest
Other
187 stars 116 forks source link

`databricks_connection` resource is throwing `Error: cannot read connection: invalid ID:` after creating a connection for Lakehouse Federation #119

Closed flaviomalavazi closed 5 months ago

flaviomalavazi commented 5 months ago

When creating a new external connection for Lakehouse Federation, terraform creates the resource but fails to retrieve the ID, throwing the message:

│ Error: cannot read connection: invalid ID: 
│ 
│   with databricks_connection.postgresql,
│   on unity_catalog_management.tf line 8, in resource "databricks_connection" "postgresql":
│    8: resource "databricks_connection" "postgresql" {
│ 
╵
Releasing state lock. This may take a few moments...

After trying to apply the same config again, it throws the "Connection already exists" error

Sample code to reproduce:

terraform {
  required_providers {

    databricks = {
      source  = "databricks/databricks"
      version = "1.35.0"
    }
}
}

provider "databricks" {
  auth_type = "azure-cli"
  alias     = "workspace"
  host      = module.databricks_workspace.workspace_url
}

resource "databricks_connection" "postgresql" {
  provider        = databricks.workspace
  name            = "lakehouse_federation_postgresql_tf"
  connection_type = "POSTGRESQL"
  comment         = "PostgreSQL Lakehouse Federation Connection"
  options = {
    host     = "HOST"
    port     = "5432"
    user     = user
    password = pwd
  }
}