Skip to content

Commit aa18976

Browse files
authored
Update cloud functions to reuse topic defined in module (#14)
* Update cloud functions to reuse topic defined in module * Ran terraform fmt to conform to style changes
1 parent 8b1aa7e commit aa18976

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

tf/cloud-functions-gen2/cloud-function.tf

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,11 @@ resource "google_cloudfunctions2_function" "function" {
4747
event_trigger {
4848
trigger_region = "us-central1"
4949
event_type = "google.cloud.pubsub.topic.v1.messagePublished"
50-
pubsub_topic = google_pubsub_topic.topic.id
50+
pubsub_topic = module.pubsub.info.request_topic.topic_id
5151
retry_policy = "RETRY_POLICY_RETRY"
5252
}
5353
}
5454

55-
resource "google_pubsub_topic" "topic" {
56-
name = "cloudfunctions-push-topic-${terraform.workspace}"
57-
}
58-
5955
resource "google_storage_bucket" "bucket" {
6056
name = "${terraform.workspace}-gcf-source" # Every bucket name must be globally unique
6157
location = "US"
@@ -88,13 +84,6 @@ variable "functionsource" {
8884
}
8985

9086
output "pubsub_info" {
91-
value = {
92-
request_topic = {
93-
topic_name = google_pubsub_topic.topic.name
94-
subscription_name = "n/a" # subscription name is not required for cloud functions
95-
}
96-
97-
response_topic = module.pubsub.info.response_topic
98-
}
87+
value = module.pubsub.info
9988
description = "Info about the request/response pubsub topics and subscription to use in the test"
10089
}

tf/modules/pubsub/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ output "info" {
8989
value = {
9090
request_topic = {
9191
topic_name = google_pubsub_topic.request.name
92+
topic_id = google_pubsub_topic.request.id
9293
subscription_name = google_pubsub_subscription.request_subscription.name
9394
}
9495

0 commit comments

Comments
 (0)