File tree Expand file tree Collapse file tree 10 files changed +22
-38
lines changed
examples/pubsub_scheduled_multiple Expand file tree Collapse file tree 10 files changed +22
-38
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ Then perform the following commands on the root folder:
5858| message\_ data | The data to send in the topic message. | string | ` "dGVzdA==" ` | no |
5959| project\_ id | The ID of the project where the resources will be created | string | n/a | yes |
6060| region | The region in which resources will be applied. | string | n/a | yes |
61- | scheduler\_ job | The Cloud Scheduler job instance | any | ` "null" ` | no |
61+ | scheduler\_ job | An existing Cloud Scheduler job instance | any | ` "null" ` | no |
6262| time\_ zone | The timezone to use in scheduler | string | ` "Etc/UTC" ` | no |
6363| topic\_ name | Name of pubsub topic connecting the scheduled job and the function | string | ` "test-topic" ` | no |
6464
@@ -67,6 +67,7 @@ Then perform the following commands on the root folder:
6767| Name | Description |
6868| ------| -------------|
6969| name | The name of the job created |
70+ | pubsub\_ topic\_ name | PubSub topic name |
7071| scheduler\_ job | The Cloud Scheduler job instance |
7172
7273<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Original file line number Diff line number Diff line change 1- # Simple Project
1+ # Multiple Cloud Functions sharing the same Cloud Scheduler
22
33This example module schedules a job to publish a message to a Pub/Sub topic every 5 minutes, which will trigger a CloudFunctions function.
44
@@ -19,6 +19,6 @@ More information is in the [root readme](../../README.md#app-engine).
1919| ------| -------------|
2020| name | The name of the job created |
2121| project\_ id | The project ID |
22- | scheduler\_ job | The Cloud Scheduler job instance |
22+ | scheduler\_ job | An existing Cloud Scheduler job instance |
2323
2424<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2121 * @param {!Object } event Event payload and metadata.
2222 * @param {!Function } callback Callback function to signal completion.
2323 */
24- exports . doSomething = ( event ) => {
24+ exports . doSomething2 = ( event ) => {
2525 console . log ( "Received event 2" ) ;
2626 console . log ( event ) ;
2727} ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -25,10 +25,6 @@ provider "google-beta" {
2525}
2626
2727module "pubsub_scheduled_1" {
28- providers = {
29- google = google- beta
30- }
31-
3228 source = " ../../"
3329 project_id = var. project_id
3430 job_name = " pubsub-example"
@@ -41,16 +37,12 @@ module "pubsub_scheduled_1" {
4137}
4238
4339module "pubsub_scheduled_2" {
44- providers = {
45- google = google- beta
46- }
47-
4840 source = " ../../"
4941 project_id = var. project_id
50- function_entry_point = " doSomething "
42+ function_entry_point = " doSomething2 "
5143 function_source_directory = " ${ path . module } /function_source_2"
5244 function_name = " testfunction-2"
5345 region = var. region
54- topic_name = " pubsub-1 "
46+ topic_name = module . pubsub_scheduled_1 . pubsub_topic_name
5547 scheduler_job = module. pubsub_scheduled_1 . scheduler_job
5648}
Original file line number Diff line number Diff line change @@ -26,6 +26,6 @@ output "project_id" {
2626
2727output "scheduler_job" {
2828 value = module. pubsub_scheduled_1 . scheduler_job
29- description = " The Cloud Scheduler job instance"
29+ description = " An existing Cloud Scheduler job instance"
3030}
3131
Original file line number Diff line number Diff line change 1919 *****************************************/
2020
2121resource "google_cloud_scheduler_job" "job" {
22- count = var. scheduler_job == null ? 1 : 0
22+ count = var. scheduler_job == null ? 1 : 0
2323
2424 name = var. job_name
2525 project = var. project_id
@@ -39,11 +39,11 @@ resource "google_cloud_scheduler_job" "job" {
3939 *****************************************/
4040
4141module "pubsub_topic" {
42- source = " terraform-google-modules/pubsub/google"
43- version = " ~> 1.0"
44- topic = var. topic_name
45- project_id = var. project_id
46- enable = var. scheduler_job == null ? true : false
42+ source = " terraform-google-modules/pubsub/google"
43+ version = " ~> 1.0"
44+ topic = var. topic_name
45+ project_id = var. project_id
46+ create_topic = var. scheduler_job == null ? true : false
4747}
4848
4949/* *****************************************
@@ -57,7 +57,7 @@ module "main" {
5757 entry_point = var. function_entry_point
5858 event_trigger = {
5959 event_type = " google.pubsub.topic.publish"
60- resource = module.pubsub_topic.topic
60+ resource = var.scheduler_job == null ? module.pubsub_topic.topic : var.topic_name
6161 }
6262 name = var. function_name
6363 project_id = var. project_id
Original file line number Diff line number Diff line change 1515 */
1616
1717output "name" {
18- value = google_cloud_scheduler_job. job . * . name
18+ value = var . scheduler_job == null ? google_cloud_scheduler_job. job . 0 . name : var . scheduler_job . name
1919 description = " The name of the job created"
2020}
2121
2222output "scheduler_job" {
2323 value = var. scheduler_job == null ? google_cloud_scheduler_job. job : var. scheduler_job
2424 description = " The Cloud Scheduler job instance"
2525}
26+
27+ output "pubsub_topic_name" {
28+ value = var. scheduler_job == null ? module. pubsub_topic . topic : var. topic_name
29+ description = " PubSub topic name"
30+ }
Original file line number Diff line number Diff line change @@ -143,6 +143,6 @@ variable "time_zone" {
143143
144144variable "scheduler_job" {
145145 type = any
146- description = " The Cloud Scheduler job instance"
146+ description = " An existing Cloud Scheduler job instance"
147147 default = null
148148}
You can’t perform that action at this time.
0 commit comments