databricks / terraform-provider-databricks

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

[ISSUE] Issue destroying databricks_workspace_conf after setting maxTokenLifetimeDays field #3316

Open jiropardo opened 4 months ago

jiropardo commented 4 months ago

Configuration

resource "databricks_workspace_conf" "this" {
provider = databricks.workspace
custom_config = {
"enableIpAccessLists" : true,
"maxTokenLifetimeDays": 90
}
}

Expected Behavior

It should be possible to destroy the resource databricks_workspace_conf or to remove the "maxTokenLifetimeDays" field after setting it to some value

Actual Behavior

Currently destroying databricks_workspace_conf is not allowed after setting maxTokenLifetimeDays to a value. It throws the error │ Error: cannot delete workspace conf: Some values are not allowed: {"maxTokenLifetimeDays":""}

Steps to Reproduce

  1. create a databricks_workspace_conf resource

2) Remove or comment the field maxTokenLifetimeDays and run apply or try destroying the entire resource. Terraform will return

Error: cannot update workspace conf: Some values are not allowed: {"maxTokenLifetimeDays":""}

3) Try adding the field "maxTokenLifetimeDays": 90 back and terraform will pass

4) Try destroying the resource after adding maxTokenLifetimeDays back, Terraform will fail with the same error even after adding it back

It looks like once the value maxTokenLifetimeDays is set once, the resource gets into a state where it cannot be destroyed in Terraform

Terraform and provider versions

provider registry.terraform.io/databricks/databricks v1.37.1

Is it a regression?

Debug Output

2024-02-29T10:07:57.769-0600 [DEBUG] provider.terraform-provider-databricks_v1.37.1: PATCH /api/2.0/workspace-conf

{ "enableIpAccessLists": "false", "maxTokenLifetimeDays": "" } < HTTP/2.0 400 Bad Request < { < "error_code": "BAD_REQUEST", < "message": "Some values are not allowed: {\"maxTokenLifetimeDays\":\"\"}" < }: @caller=/home/runner/work/terraform-provider-databricks/terraform-provider-databricks/logger/logger.go:33 tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=3cac0fb4-cf9b-da69-2908-8c39c9484e2b @module=databricks tf_resource_type=databricks_workspace_conf tf_rpc=ApplyResourceChange timestamp=2024-02-29T10:07:57.768-0600 2024-02-29T10:07:57.769-0600 [ERROR] provider.terraform-provider-databricks_v1.37.1: Response contains error diagnostic: tf_resource_type=databricks_workspace_conf diagnostic_summary="cannot delete workspace conf: Some values are not allowed: {\"maxTokenLifetimeDays\":\"\"}" tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=3cac0fb4-cf9b-da69-2908-8c39c9484e2b @caller=/home/runner/work/terraform-provider-databricks/terraform-provider-databricks/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/diag/diagnostics.go:62 diagnostic_detail="" diagnostic_severity=ERROR tf_proto_version=5.4 tf_rpc=ApplyResourceChange @module=sdk.proto timestamp=2024-02-29T10:07:57.768-0600 2024-02-29T10:07:57.778-0600 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot 2024-02-29T10:07:57.778-0600 [ERROR] vertex "databricks_workspace_conf.this (destroy)" error: cannot delete workspace conf: Some values are not allowed: {"maxTokenLifetimeDays":""}

Error: cannot delete workspace conf: Some values are not allowed: {"maxTokenLifetimeDays":""}

Important Factoids

Would you like to implement a fix?

aravishdatabricks commented 4 months ago

@jiropardo Did you try force option?