Skip to content

Commit aae3181

Browse files
feat: added cloudsql serverless_export (#530)
Co-authored-by: Imran Nayer <[email protected]>
1 parent c769aa5 commit aae3181

File tree

7 files changed

+16
-0
lines changed

7 files changed

+16
-0
lines changed

examples/postgresql-backup-provided-service-account/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This example shows how to create:
55
- a PostgreSQL Cloud SQL Instance
66
- A GCS Bucket for storing the Backup
77
- The Workflows for exports (external backups) and (internal) backups
8+
- The Workflows with serverless export
89

910
## Run Terraform
1011

examples/postgresql-backup-provided-service-account/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module "backup" {
5353
backup_retention_time = 1
5454
backup_schedule = "5 * * * *"
5555
export_schedule = "10 * * * *"
56+
use_serverless_export = true
5657
service_account = "${data.google_project.test_project.number}[email protected]"
5758
}
5859

modules/backup/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fetch workflows.googleapis.com/Workflow
7171
| sql\_instance | The name of the SQL instance to backup | `string` | n/a | yes |
7272
| sql\_instance\_replica | The name of the SQL instance replica to export | `string` | `null` | no |
7373
| unique\_suffix | Unique suffix to add to scheduler jobs and workflows names. | `string` | `""` | no |
74+
| use\_serverless\_export | Whether to use serverless export for DB export | `bool` | `false` | no |
7475
| use\_sql\_instance\_replica\_in\_exporter | Whether or not to use replica instance on exporter workflow. | `bool` | `false` | no |
7576

7677
## Outputs

modules/backup/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ resource "google_workflows_workflow" "sql_export" {
113113
enableConnectorParams = var.enable_connector_params
114114
connectorParamsTimeout = var.connector_params_timeout
115115
logDbName = var.log_db_name_to_export
116+
serverlessExport = var.use_serverless_export
116117
})
117118
}
118119

modules/backup/metadata.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ spec:
102102
description: Unique suffix to add to scheduler jobs and workflows names.
103103
type: string
104104
default: ""
105+
- name: use_serverless_export
106+
description: Whether to use serverless export for DB export
107+
type: bool
108+
default: false
105109
outputs:
106110
- name: backup_workflow_name
107111
description: The name for internal backup workflow

modules/backup/templates/export.yaml.tftpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ main:
6161
body:
6262
exportContext:
6363
databases: [$${database}]
64+
offload: "${serverlessExport}"
6465
uri: $${"${gcsBucket}/${instanceName}-" + database + "-" + backupTime + %{ if compressExport == true }".sql.gz"%{ else }".sql"%{ endif }}
6566
%{ endif }
6667

@@ -109,5 +110,6 @@ main:
109110
body:
110111
exportContext:
111112
databases: $${databases}
113+
offload: "${serverlessExport}"
112114
uri: $${"${gcsBucket}/${instanceName}-" + backupTime + %{ if compressExport == true }".sql.gz"%{ else }".sql"%{ endif }}
113115
%{ endif }

modules/backup/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,9 @@ variable "sql_instance_replica" {
132132
type = string
133133
default = null
134134
}
135+
136+
variable "use_serverless_export" {
137+
description = "Whether to use serverless export for DB export"
138+
type = bool
139+
default = false
140+
}

0 commit comments

Comments
 (0)