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

Provider fails with Unable to Login to <X> If the SA or Administrator Password Changes #80

Open
vsabella opened this issue Feb 29, 2024 · 3 comments

Comments

@vsabella
Copy link

Whenver the administrator password changes, re-running terraform results in this error:

│ Error: unable to read user [abc]: mssql: login error: Login failed for user 'my_sa_account'.│ 
│   on ...... , in resource "mssql_user" "user":
│   22: resource "mssql_user" "user" {

This is actually a bit obvious when you look at the provider design - the login to the server is provided to the resource, not the provider itself. So if the SA login changes, the resource is unable to "update its state". It's storing the login in the terraform state file.

Ideally this should be taking the host/login from the provider registration, not this.

resource "mssql_user" "user" {
  server {
    host = var.endpoint
    login {
      username = var.administrator_login
      password = var.administrator_password
    }
  }
@maxnsdia
Copy link

We experienced this as well and switching back to the old password also did not work, somehow both passwords were in the state file in different places.
Would appreciate a fix because we have mandatory secret rotation of our sa password and every time this happens it breaks our pipeline.
Our fix now was manually inserting the new password in all state files which fixed the problem but is of course not something we would want to do each time.

@folkerttenkate
Copy link

Exactly the same issue here, except using the azure_login option....

azure_login { tenant_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" client_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" client_secret = "terriblySecretSecret" }

Is great until you rotate your secrets for security reasons... This should be part of the provider configuration and no the actual mssql_user configuration which it is now, which I believe is why it is stored in the state file.

@WolfyUK
Copy link

WolfyUK commented Sep 23, 2024

My workaround to the above was to manually edit the tfstate to set the new password. Not ideal, sure, but it unblocked me!

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

4 participants