Skip to content

Commit d27f1ed

Browse files
modular-magiciannat-henderson
authored andcommitted
Add support for new-style cloud functions triggers. (#2412)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
1 parent a1e7a44 commit d27f1ed

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

google/resource_cloudfunctions_function.go

+5
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,11 @@ func expandEventTrigger(configured []interface{}, project string) *cloudfunction
607607
eventType := data["event_type"].(string)
608608
shape := ""
609609
switch {
610+
case strings.HasPrefix(eventType, "google.storage.object."):
611+
shape = "projects/%s/buckets/%s"
612+
case strings.HasPrefix(eventType, "google.pubsub.topic."):
613+
shape = "projects/%s/topics/%s"
614+
// Legacy style triggers
610615
case strings.HasPrefix(eventType, "providers/cloud.storage/eventTypes/"):
611616
shape = "projects/%s/buckets/%s"
612617
case strings.HasPrefix(eventType, "providers/cloud.pubsub/eventTypes/"):

google/resource_cloudfunctions_function_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ resource "google_cloudfunctions_function" "function" {
637637
timeout = 61
638638
entry_point = "helloGCS"
639639
event_trigger {
640-
event_type = "providers/cloud.storage/eventTypes/object.change"
640+
event_type = "google.storage.object.finalize"
641641
resource = "${google_storage_bucket.bucket.name}"
642642
failure_policy {
643643
retry = true
@@ -667,7 +667,7 @@ resource "google_cloudfunctions_function" "function" {
667667
timeout = 61
668668
entry_point = "helloGCS"
669669
event_trigger {
670-
event_type = "providers/cloud.storage/eventTypes/object.change"
670+
event_type = "google.storage.object.finalize"
671671
resource = "${google_storage_bucket.bucket.name}"
672672
}
673673
}`, bucketName, zipFilePath, functionName)

website/docs/r/cloudfunctions_function.html.markdown

+5-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ Deprecated. Use `event_trigger.failure_policy.retry` instead.
8585

8686
The `event_trigger` block supports:
8787

88-
* `event_type` - (Required) The type of event to observe. For example: `"providers/cloud.storage/eventTypes/object.change"`
89-
and `"providers/cloud.pubsub/eventTypes/topic.publish"`. See the documentation on [calling Cloud Functions](https://cloud.google.com/functions/docs/calling/)
90-
for a full reference. Only Cloud Storage and Cloud Pub/Sub triggers are supported at this time.
88+
* `event_type` - (Required) The type of event to observe. For example: `"google.storage.object.finalize"`.
89+
See the documentation on [calling Cloud Functions](https://cloud.google.com/functions/docs/calling/) for a full reference.
90+
Only Cloud Storage and Cloud Pub/Sub triggers are supported at this time.
91+
Legacy Cloud Storage and Cloud Pub/Sub triggers are also supported, such as `"providers/cloud.storage/eventTypes/object.change"`
92+
and `"providers/cloud.pubsub/eventTypes/topic.publish"`.
9193

9294
* `resource` - (Required) Required. The name of the resource from which to observe events, for example, `"myBucket"`
9395

0 commit comments

Comments
 (0)