-
Notifications
You must be signed in to change notification settings - Fork 14
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
split into a resource that doesn't create the db #3
Comments
implementation piece: variable "db_server_fqdn" {
description = "Full qualified domain name of the database sever. The server where to create the database. In the form xxxx.database.windows.net"
type = string
}
variable "db_name" {
description = "The name of the database to run the seed script against."
type = string
}
variable "sql_admin_username" {
description = "The administrator username of the SQL Server to use for launching the seed script."
type = string
}
variable "sql_admin_password" {
description = "The administrator password of the SQL Server to use for launching the seed script."
type = string
sensitive = true
}
variable "init_script_file" {
description = "SQL Script file name to seed the database. Example: db-init.sql."
type = string
}
resource "null_resource" "seed" {
provisioner "local-exec" {
environment = {
SQLCMDPASSWORD = var.sql_admin_password # Required so that the password does not spill to console when the resource fails
}
command = "sqlcmd -U ${var.sql_admin_username} -S ${var.db_server_fqdn} -d ${var.db_name} -i ${var.init_script_file}"
}
}
|
Note: i dropped the log file piece. it wasnt working for me in TF 1.5.x |
for sure i can use the null resource but the beauty of a dedicated resource is the way it tracks changes and executes and eventually doesn't require sql cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this would have more utility IMO if it didn't have to provision the db as well. It could be triggered similar to the null providers triggers
The text was updated successfully, but these errors were encountered: