databricks / terraform-provider-databricks

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

[ISSUE] Issue with `databricks_mws_networks` resource: attempts to update a resource that does not support being updated #2839

Open jaloren opened 1 year ago

jaloren commented 1 year ago

Configuration

resource "databricks_mws_networks" "instance" {
  provider           = databricks.accounts
  account_id         = var.databricks_account_id
  network_name       = "${var.workspace_name}-network"
  security_group_ids = var.security_group_ids
  subnet_ids         = var.subnet_ids
  vpc_id             = var.vpc_id

  vpc_endpoints {
    dataplane_relay = [var.vpc_endpoints.dataplane_relay]
    rest_api        = [var.vpc_endpoints.rest_api]
  }
}

Expected Behavior

the network and workspace should have been replaced. In other words, the resource needs to be deleted and then created a new. this is because the actual infra resource doesn't allow updates.

Actual Behavior

Error: doesn't support update

  with module.prod_ingestion_workspaces.module.ingestion.module.create_workspace.databricks_mws_networks.instance,
  on ../../modules/databricks-workspace/creation/main.tf line 1, in resource "databricks_mws_networks" "instance":
   1: resource "databricks_mws_networks" "instance" {

Steps to Reproduce

Using terraform resources

  1. create a network endpoint and bind two vpc endpoints for relay and rest api.
  2. create workspace where this network endpoint is assigned to it.
  3. in terraform, update the network endpoint TF resource to use different vpc endpoints.
  4. attemt a terraform apply

Terraform and provider versions

Terraform v1.5.6
on darwin_amd64
+ provider registry.terraform.io/databricks/databricks v1.24.1
+ provider registry.terraform.io/hashicorp/aws v5.14.0
+ provider registry.terraform.io/hashicorp/time v0.9.1
nkvuong commented 1 year ago

the underlying resource does not support update, so you would need to remove the resource and recreate it (remove the resource, run TF apply, re-add it and run TF apply once more)

jaloren commented 1 year ago

@nkvuong which is a bug in the terraform provider. The terraform resource should be designed such that an update means a replace. This is a common behavior for a lot of infra which providers need to account for. The alternative is painful terraform state surgery and manual changes to the infra.

mgyucht commented 1 year ago

@nkvuong can we mark attributes with "ForceNew = true" as needed?

nkvuong commented 1 year ago

@mgyucht we can add it, but the current API behaviour of network & workspace object requires a special workaround already. Allowing this resource to be destroyed and recreated would still run into the same issue