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

set application as an admin #62

Open
nazirakz opened this issue Jul 11, 2023 · 2 comments
Open

set application as an admin #62

nazirakz opened this issue Jul 11, 2023 · 2 comments

Comments

@nazirakz
Copy link

Hello! I'm trying to do a secret-less connection between the app service and Azure SQL by using mssql_user
below the code:

resource "mssql_user" "web" {
server {
host = var.host_name
azure_login {
tenant_id = var.tenant_id
client_id = var.sql_sp_client_id (used client id of the application that is the ad admin of the SQl server)
client_secret = data.azurerm_key_vault_secret.AAD_admin_password.value
}
}

object_id = var.webapp_principal_id (used oblect_id of the webapp service principal )
database = var.database_name
username = var.webapp_name
roles = ["db_datareader", "db_datawriter"]
}

data "azurerm_key_vault_secret" "AAD_admin_password" {
name = "terraform-iac-secret"
key_vault_id = local.key_vault_id
}

As an admin, I set an application by using
azuread_administrator {
login_username = var.sql_server_ad_admin_username
object_id = var.sql_server_ad_admin_object_id
}

but in the end it throughs me this error: Error: unable to create user [tenant-DB].[wapp_name]: mssql: login error: Login failed for user ''.

Please, could you provide me with some feedback, thanks.

@JoshDouglasOU
Copy link

did you ever get this resolved. i think i have the same issue.

my sp is part of a group that is entra admin on the sql server, but i get getting login failed

@Masahigo
Copy link

Masahigo commented Jan 23, 2024

I got it working at least. I was getting that same error if/when the Service Principal's client secret was rotated. The issue was that this TF provider stores the initial client secret to remote state and doesn't support the use case of rotating the credential after that.

Check my comment from here: https://dev.to/masahigo/comment/2800b

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