From c06e656e627fef9202c1dd6d248ae777bdb76345 Mon Sep 17 00:00:00 2001 From: "ryan-distrust.co" Date: Mon, 15 May 2023 00:03:44 -0400 Subject: [PATCH] terraform_modules/digitalocean_database_cluster: pass necessary flags to psql --- .../digitalocean_database_cluster/main.tf | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/terraform_modules/digitalocean_database_cluster/main.tf b/terraform_modules/digitalocean_database_cluster/main.tf index 2d34649..9114a10 100644 --- a/terraform_modules/digitalocean_database_cluster/main.tf +++ b/terraform_modules/digitalocean_database_cluster/main.tf @@ -39,13 +39,23 @@ resource "digitalocean_database_user" "default_users" { name = each.key provisioner "local-exec" { - command = "GRANT ALL ON DATABASE ${each.key} TO ${each.key}" - interpreter = ["psql", "${local.base_connection_string}/${each.key}"] + command = "GRANT ALL ON DATABASE ${each.key} TO ${each.key};" + interpreter = [ + "psql", + "-v", "ON_ERROR_STOP=1", + "${local.base_connection_string}/${each.key}", + "-c" + ] } provisioner "local-exec" { command = "GRANT ALL ON SCHEMA public TO ${each.key}" - interpreter = ["psql", "${local.base_connection_string}/${each.key}"] + interpreter = [ + "psql", + "-v", "ON_ERROR_STOP=1", + "${local.base_connection_string}/${each.key}", + "-c" + ] } # Note: provisioners depend on databases existing