This Terraform module provisions a Google Cloud Function for scheduled cloudSQL database exports.
Copyright 2019-2024 NephoSolutions srl, Sebastian Trebitz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
| Name | Version |
|---|---|
| terraform | >= 0.13 |
| >= 3.53 |
| Name | Version |
|---|---|
| 6.13.0 |
| Name | Source | Version |
|---|---|---|
| export_function | terraform-google-modules/event-function/google | ~> 4.0 |
| pubsub_topic | terraform-google-modules/pubsub/google | ~> 7.0 |
| Name | Type |
|---|---|
| google_cloud_scheduler_job.export | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| export_jobs | Set of export Jobs | set(object({ |
n/a | yes |
| function_labels | A set of key/value label pairs to assign to the function. | map(string) |
{} |
no |
| function_name | The name to apply to the function. | string |
"cloudsql-export" |
no |
| function_runtime | The Cloud Run functions execution environment. | string |
"python39" |
no |
| function_service_account_email | The service account to run the function as. | string |
n/a | yes |
| function_source_bucket_create | Whether to create a new bucket or use an existing one. | bool |
true |
no |
| function_source_bucket_labels | A set of key/value label pairs to assign to the source bucket. | map(string) |
{} |
no |
| function_source_bucket_name | The name of the function source archive bucket. | string |
"" |
no |
| project_id | The ID of the GCP project. Defaults to the provider project configuration, if left empty. | string |
n/a | yes |
| region | The region to deploy the resources in. | string |
n/a | yes |
| topic_labels | A set of key/value label pairs to assign to the pubsub topic. | map(string) |
{} |
no |
| topic_name | Name of pubsub topic connecting the scheduled job and the function | string |
"cloudsql-export" |
no |
| Name | Description |
|---|---|
| function_name | The name of the function. |
| scheduler_job_id | Map of job identifiers with format projects/{{project}}/locations/{{region}}/jobs/{{name}} |
| subscription_names | The name list of Pub/Sub subscriptions |
| subscription_paths | The path list of Pub/Sub subscriptions |
| topic_id | The ID of the Pub/Sub topic |
| topic_name | The name of the Pub/Sub topic |
| topic_uri | The URI of the Pub/Sub topic |
These sections describe requirements for using this module.
Note that this module requires App Engine being configured in the specified project/region. This is because Google Cloud Scheduler is dependent on the project being configured with App Engine.
The recommended way to create projects with App Engine enabled is via the Project Factory module. There is an example of how to create the project within that module
A service account with the following roles must be used to provision the resources of this module:
- Cloudfunctions Developer:
roles/cloudfunctions.developer - Cloudscheduler Admin:
roles/cloudscheduler.admin - IAM ServiceAccount User:
roles/iam.serviceAccountUser - PubSub Editor:
roles/pubsub.editor - Storage Admin:
roles/storage.admin
A project with the following APIs enabled must be used to host the resources of this module:
- App Engine Admin API:
appengine.googleapis.com - Cloud Build API:
cloudbuild.googleapis.com - Cloud Functions API:
cloudfunctions.googleapis.com - Cloud PubSub API:
pubsub.googleapis.com - Cloud Scheduler API:
cloudscheduler.googleapis.com