Skip to content

Commit

Permalink
feat: add Suffix to backup configurations (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensf committed Dec 2, 2022
1 parent f36347e commit 0ea1968
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions modules/backup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fetch workflows.googleapis.com/Workflow
| scheduler\_timezone | The Timezone in which the Scheduler Jobs are triggered | `string` | `"Etc/GMT"` | no |
| service\_account | The service account to use for running the workflow and triggering the workflow by Cloud Scheduler - If empty or null a service account will be created. If you have provided a service account you need to grant the Cloud SQL Admin and the Workflows Invoker role to that | `string` | `null` | no |
| sql\_instance | The name of the SQL instance to backup | `string` | n/a | yes |
| unique\_suffix | Unique suffix to add to scheduler jobs and workflows names. | `string` | `""` | no |

## Outputs

Expand Down
8 changes: 4 additions & 4 deletions modules/backup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ data "google_sql_database_instance" "backup_instance" {
################################
resource "google_workflows_workflow" "sql_backup" {
count = var.enable_internal_backup ? 1 : 0
name = "sql-backup-${var.sql_instance}"
name = "sql-backup-${var.sql_instance}${var.unique_suffix}"
region = var.region
description = "Workflow for backing up the CloudSQL Instance "
project = var.project_id
Expand All @@ -73,7 +73,7 @@ resource "google_workflows_workflow" "sql_backup" {

resource "google_cloud_scheduler_job" "sql_backup" {
count = var.enable_internal_backup ? 1 : 0
name = "sql-backup-${var.sql_instance}"
name = "sql-backup-${var.sql_instance}${var.unique_suffix}"
project = var.project_id
region = var.region
description = "Managed by Terraform - Triggers a SQL Backup via Workflows"
Expand All @@ -97,7 +97,7 @@ resource "google_cloud_scheduler_job" "sql_backup" {
################################
resource "google_workflows_workflow" "sql_export" {
count = var.enable_export_backup ? 1 : 0
name = "sql-export-${var.sql_instance}"
name = "sql-export-${var.sql_instance}${var.unique_suffix}"
region = var.region
description = "Workflow for backing up the CloudSQL Instance"
project = var.project_id
Expand All @@ -115,7 +115,7 @@ resource "google_workflows_workflow" "sql_export" {

resource "google_cloud_scheduler_job" "sql_export" {
count = var.enable_export_backup ? 1 : 0
name = "sql-export-${var.sql_instance}"
name = "sql-export-${var.sql_instance}${var.unique_suffix}"
project = var.project_id
region = var.region
description = "Managed by Terraform - Triggers a SQL Export via Workflows"
Expand Down
6 changes: 6 additions & 0 deletions modules/backup/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,9 @@ variable "compress_export" {
type = bool
default = true
}

variable "unique_suffix" {
description = "Unique suffix to add to scheduler jobs and workflows names."
type = string
default = ""
}

0 comments on commit 0ea1968

Please sign in to comment.