betr-io / terraform-provider-mssql

Terraform provider for Microsoft SQL Server
https://registry.terraform.io/providers/betr-io/mssql/latest
MIT License
36 stars 29 forks source link

resource mssql_user reads server's password from the state rather than configuration #49

Closed PavelPikat closed 1 year ago

PavelPikat commented 2 years ago

We have created some SQL users using the mssql_user resource, and then changed SQL Server's password. The mssql_user now fails to check the existing user, because it fails to authenticate. Apparently it doesn't use the new password that is passed to it in Terraform's configuration, and instead uses the old password that's already in state.

Sample config:

resource "mssql_user" "existing-sql" {
  server {
    host = "somehost
    login {
      username = "someuser"
      password = "somepw"
    }
  }
  database = "somedb"
  username ="dbuser"
  password = "dbuserpw"
}

I also confirmed this is provider's bug by changing the password manually in the state's JSON file. After that, the terraform plan can authenticate without issues.

Expected behaviour

mssql_user resoruce should always use server's login username and password from the configuration rather than the state

magne commented 1 year ago

I'm closing this as #50 now provides more contextual information.