databricks / terraform-provider-databricks

Databricks Terraform Provider
https://registry.terraform.io/providers/databricks/databricks/latest
Other
445 stars 384 forks source link

[ISSUE] Wrong value for ID output in `databricks_mws_workspaces` resource #1707

Closed Israphel closed 1 year ago

Israphel commented 1 year ago

Configuration

# ID
output "id" {
  description = "Canonical unique identifier for the workspace."
  value       = databricks_mws_workspaces.workspace.id
}

Expected Behavior

I was following this documentation and the workspace id is required for construct the external-id. According to the doc, an ID looks like a number (the same id you see in the URL), but the output is giving me something like "abcd-abcd-abcd-abcd/1234567689"

Actual Behavior

Only the Workspace ID should be in the output.

Terraform and provider versions

1.6.1

My workaround

I made it work by only grabbing the digits after the /, but I still think the output called ID should be only the ID.

# Databricks SQL Global Config (us-west-2)
module "databricks-sql-global-config-us-west-2" {
  source  = "app.terraform.io/split/sql-global-config/databricks"
  version = "0.1.7"

  enable_serverless_compute = local.config[local.environment][data.aws_region.usw2.name]["workspace"]["enable_serverless_sql"]
  workspace_id              = element(split("/", module.databricks-workspace-us-west-2.id), 1)
  environment               = local.environment

  providers = {
    aws        = aws.usw2
    databricks = databricks.usw2
  }
}
nkvuong commented 1 year ago

@Israphel could you check if databricks_mws_workspaces.workspace.workspace_id gives you the id of the workspace? If so, then we need to add it to the doc

Israphel commented 1 year ago

@Israphel could you check if databricks_mws_workspaces.workspace.workspace_id gives you the id of the workspace? If so, then we need to add it to the doc

it does, thank you.

Israphel commented 1 year ago

also, is there a way to get the "current" workspace with this? https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/mws_workspaces

but without authenticating with account ID and without getting all the workspaces. That way, my sql-global-config module could be able to get the workspace ID by itself.

nkvuong commented 1 year ago

@Israphel we need to check if there is an API for that, as there is currently no easy way to do it directly with the workspace API