Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] databricks_sql_permissions causes perpetual plan changes: catalog becomes database/default #620

Closed
vynaloze opened this issue Apr 29, 2021 · 0 comments · Fixed by #638
Assignees

Comments

@vynaloze
Copy link

[split from #619]

Terraform Version

Terraform v0.14.10
+ provider registry.terraform.io/databrickslabs/databricks v0.3.3

Affected Resource(s)

  • databricks_sql_permissions

Environment variable names

DATABRICKS_HOST
DATABRICKS_TOKEN

Terraform Configuration Files

There is only a single database in this scenario. The use case is that I want to enable access to any new databases (possibly created in the future) to data_admin, while denying data_read_only access to them.

resource "databricks_sql_permissions" "catalog" {
  catalog = true

  privilege_assignments {
    principal = "data_admin"
    privileges = [
      "SELECT",
      "CREATE",
      "MODIFY",
      "USAGE",
      "READ_METADATA",
    ]
  }
}

resource "databricks_sql_permissions" "database" {
  database = "test"

  privilege_assignments {
    principal = "data_admin"
    privileges = [
      "SELECT",
      "CREATE",
      "MODIFY",
      "USAGE",
      "READ_METADATA",
    ]
  }

  privilege_assignments {
    principal = "data_read_only"
    privileges = [
      "SELECT",
      "USAGE",
      "READ_METADATA",
    ]
  }
}

Expected Behavior

No changes should be detected when running subsequent plans after initial apply

Actual Behavior

After initial apply, running plan produces following output, given configuration file above:

  # databricks_sql_permissions.catalog must be replaced
-/+ resource "databricks_sql_permissions" "catalog" {
      - anonymous_function = false -> null
      - any_file           = false -> null
      ~ catalog            = false -> true # forces replacement
      ~ cluster_id         = "REDACTED" -> (known after apply)
      ~ id                 = "database/default" -> (known after apply)
        # (1 unchanged attribute hidden)

        # (1 unchanged block hidden)
    }

  # databricks_sql_permissions.database will be updated in-place
  ~ resource "databricks_sql_permissions" "database" {
        id                 = "database/test"
        # (5 unchanged attributes hidden)

      ~ privilege_assignments {
          ~ principal  = "data_read_only" -> "data_admin"
          ~ privileges = [
              + "CREATE",
              + "MODIFY",
                # (3 unchanged elements hidden)
            ]
        }
      ~ privilege_assignments {
          ~ principal  = "data_admin" -> "data_read_only"
          ~ privileges = [
              - "CREATE",
              - "MODIFY",
                # (3 unchanged elements hidden)
            ]
        }
    }

(note #619 is still there, even though there are two assignments now instead of three)

Steps to Reproduce

  1. terraform apply
  2. terraform plan (or apply, whatever)
nfx added a commit that referenced this issue May 7, 2021
@nfx nfx linked a pull request May 7, 2021 that will close this issue
@nfx nfx self-assigned this May 7, 2021
nfx added a commit that referenced this issue May 7, 2021
@nfx nfx closed this as completed in #638 May 7, 2021
nfx added a commit that referenced this issue May 7, 2021
@nfx nfx mentioned this issue May 12, 2021
michael-berk pushed a commit to michael-berk/terraform-provider-databricks that referenced this issue Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants