betr-io / terraform-provider-mssql

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

Feature request - Run SQL scripts #58

Open Marcus-James-Adams opened 1 year ago

Marcus-James-Adams commented 1 year ago

When you look at the missing terraform resource roles for MS SQL now that logins & users are fixed by this much-needed provider, the only thing left is the ability to call SQL scripts with inline or from a template file

it would be lovely of this feature could be added to the provider

example psudo code

resource "mssql_code" myscript" {
  server {
    host = azurerm_mssql_server.sql_server.fully_qualified_domain_name
    login {
      username = azurerm_mssql_server.sql_server.administrator_login
      password = azurerm_mssql_server.sql_server.administrator_login_password
    }
  }
      execute_as_username = azurerm_mssql_server.sql_server.administrator_login
      execute_as_password = azurerm_mssql_server.sql_server.administrator_login_password

      # database is optional (???) in case the script needs to be applied against a specific file
      database = azurerm_mssql_database.db.name

      # script takes input from file, templatefile or expanded multiline HEREDOC format
      script = file("${path.module}/myscript.sql)

}