Closed achaussende closed 2 years ago
@achaussende can you try auth with env vars instead of databricks-cli? in real production deployments you probably won't use ~/.databrickscfg
file and rely on env vars.
I think I find my problem and it is not related to how the provider works.
The workspace was not created using the same credentials (user/pw) I am currently using during my terraform plan. But during the plan, we are reusing the same credentials for both querying the Accounts/Admin console API (host=https://accounts.cloud.databricks.com) and the workspace's API (host=https://my-workspace.cloud.databricks.com).
Using env vars and changing to another user (like a service account to us, that is created in both admin console and that I suspected to be used for workspace creation and thus, that should be present in workspace's users) instead of my personal access allows the terraform plan
command to complete.
How can I improve the authentication for our workspace lifecycle so we can manage it using Terraform only? Should we use the token output from resource.databricks_mws_workspaces
?
@achaussende username/password could be used for both accounts & workspace API communication, there's no difference.
databricks_mws_workspaces.token is just a PAT token for the same user you're calling workspace creation APIs with.
@nfx I know that both can be used for both API communication, but the credentials have to be created in both and i think, it's not that a good practice to reuse the same credentials to authenticate to the Admin console and to a workspace.
I am wondering if there is a better way so I don't have to reuse the same credentials for both API that the provider is querying.
@achaussende then you should use databricks_mws_workspaces.this.token[0].token_value
. but it's perfectly fine to reuse the same credentials for both account and things within the workspace.
Hi there,
I was upgrading the provider from 0.3.7 to 0.4.X on an existing Terraform codebase that only manages Databricks workspaces creation and then, I had an issue when refreshing the terraform state while doing a
terraform plan
. Please note that theterraform plan
command works fine in Databricks Terraform provider 0.3.7 but not in any of the 0.4.X version (even0.4.6
).Configuration
Basic Terraform code for workspace creation.
PS: Add the databricks provider configuration
Expected Behavior
What should have happened?
The
terraform plan
command should have completed without freezing nor errors.Actual Behavior
What actually happened?
When doing the refreshing state part for
databricks_mws_workspaces.workspace
, the command seems to freeze. Actually, after turning debug logging, it seems to got a 401 Unauthorized when calling an API on the wrong host (see logs below). I can only kill the command and thus, get an error.Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform plan
Terraform and provider versions
Please paste the output of
terraform version
. If version ofdatabricks
provider is not the latest (https://github.com/databrickslabs/terraform-provider-databricks/releases), please make sure to use the latest one.Debug Output
Simple output
Output with debug logging and formatting (I redacted some information)
Important Factoids
Are there anything atypical about your accounts that we should know?
Accounts API
(to create workspaces) is done using the~/.databrickscfg
file.