From 9c1eb24fd992a4ea565f2d6e7faf67e69b3da394 Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Sun, 22 Mar 2020 13:31:46 +0100 Subject: [PATCH] scheduled cloud function module: allow disabling schedule --- modules/__experimental/cloud-function-scheduled/README.md | 2 +- modules/__experimental/cloud-function-scheduled/main.tf | 1 + modules/__experimental/cloud-function-scheduled/variables.tf | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/__experimental/cloud-function-scheduled/README.md b/modules/__experimental/cloud-function-scheduled/README.md index beeb88cf70..df1edce00d 100644 --- a/modules/__experimental/cloud-function-scheduled/README.md +++ b/modules/__experimental/cloud-function-scheduled/README.md @@ -28,7 +28,7 @@ module "function" { | *function_config* | Cloud function configuration. | object({...}) | | ... | | *prefixes* | Optional prefixes for resource ids, null prefixes will be ignored. | object({...}) | | null | | *region* | Region used for all resources. | string | | us-central1 | -| *schedule_config* | Cloud function scheduler job configuration, leave data null to pass the name variable. | object({...}) | | ... | +| *schedule_config* | Cloud function scheduler job configuration, leave data null to pass the name variable, set schedule to null to disable schedule. | object({...}) | | ... | | *service_account_iam_roles* | IAM roles assigned to the service account at the project level. | list(string) | | [] | ## Outputs diff --git a/modules/__experimental/cloud-function-scheduled/main.tf b/modules/__experimental/cloud-function-scheduled/main.tf index ca197f98b1..0d3f03ff5d 100644 --- a/modules/__experimental/cloud-function-scheduled/main.tf +++ b/modules/__experimental/cloud-function-scheduled/main.tf @@ -46,6 +46,7 @@ resource "google_pubsub_topic" "topic" { } resource "google_cloud_scheduler_job" "job" { + count = var.schedule_config.schedule == null ? 0 : 1 project = var.project_id region = var.region name = lookup(local.prefixes, "job", var.name) diff --git a/modules/__experimental/cloud-function-scheduled/variables.tf b/modules/__experimental/cloud-function-scheduled/variables.tf index 6a33f37f2c..78bb4b8cac 100644 --- a/modules/__experimental/cloud-function-scheduled/variables.tf +++ b/modules/__experimental/cloud-function-scheduled/variables.tf @@ -75,7 +75,7 @@ variable "region" { } variable "schedule_config" { - description = "Cloud function scheduler job configuration, leave data null to pass the name variable." + description = "Cloud function scheduler job configuration, leave data null to pass the name variable, set schedule to null to disable schedule." type = object({ pubsub_data = string schedule = string