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

mssql_schema_permission bug #132

Open
leonfibal opened this issue Oct 5, 2023 · 2 comments
Open

mssql_schema_permission bug #132

leonfibal opened this issue Oct 5, 2023 · 2 comments

Comments

@leonfibal
Copy link

When mssql_schema_permission depends on the user (which should be created before), I get an error that schema and database must belong to the same database.

If I create a plan with mssql_sql_user only, apply it, and then create the next one (which wants to create mssql_sql_user only), there is no error.

Configuration:

data "mssql_schema" "schema" {
  name        = "schDataLake"
  database_id = data.mssql_database.database.id

  lifecycle {
    postcondition {
      condition     = self.id != null
      error_message = "Schema must exist"
    }
  }
}

resource "mssql_sql_user" "user" {
  name        = local.dl_user
  database_id = data.mssql_database.database.id
  login_id    = data.mssql_sql_login.login.id
}

resource "mssql_schema_permission" "schema_permission" {
  schema_id    = data.mssql_schema.schema.id
  principal_id = mssql_sql_user.user.id
  permission   = "SELECT"

  depends_on = [
    mssql_sql_user.user
   ]
}

Output:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform planned the following actions, but then encountered a problem:

  # mssql_sql_user.user will be created
  + resource "mssql_sql_user" "user" {
      + database_id = "56"
      + id          = (known after apply)
      + login_id    = "0x010600000000006400000000000000008875E4B7A6B3064D8F72C34AC9869B0A"
      + name        = "bg_test"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Error: Schema and Principal must belong to the same DB
│
│   with mssql_schema_permission.schema_permission,
│   on main.tf line 75, in resource "mssql_schema_permission" "schema_permission":
│   75: resource "mssql_schema_permission" "schema_permission" {
│
│ schema_id points to DB with ID 56 while principal_id points to DB with ID 0
╵
@Flasheh
Copy link

Flasheh commented Nov 3, 2023

Also hitting his issue at the moment. Would you have time to look at this @tkielar-pgs? Since this really breaks our entire flow.

@l33tCod-er
Copy link

Any update on this? Hit the same....

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

No branches or pull requests

3 participants