问题
is there a possibility to add a sql user to the azure sql via terraform? https://www.mssqltips.com/sqlservertip/5242/adding-users-to-azure-sql-databases/
Or is there a better suggestions how to create a SQL user?
Thanks
回答1:
Yes you can do it from Terraform if that is what you want to happen. I would use a null resource provider in Terraform to execute the commands from the box that is running Terraform. You could use PowerShell, CMD, etc. to connect to the database after it is created and create your user account. Here is an example of how to use the null resource provider.
I would image it would look something like this, in this example I am using the SqlServer PowerShell module.
resource "null_resource" "create-sql-user" {
provisioner "local-exec" {
command = "Add-SqlLogin -LoginName ${var.loginName} -LoginType ${var.loginType}"
interpreter = ["PowerShell", "-Command"]
}
depends_on = ["azurerm_sql_database.demo"]
}
You could of course do it with our CLI tools, but this would guarantee it is part of your Terraform deployment.
来源:https://stackoverflow.com/questions/54326033/add-azure-sql-user-with-terraform