Skip to content

Commit 457b003

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 adc6bd7 commit 457b003

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
@@ -526,6 +526,11 @@ func expandEventTrigger(configured []interface{}, project string) *cloudfunction
526526
eventType := data["event_type"].(string)
527527
shape := ""
528528
switch {
529+
case strings.HasPrefix(eventType, "google.storage.object."):
530+
shape = "projects/%s/buckets/%s"
531+
case strings.HasPrefix(eventType, "google.pubsub.topic."):
532+
shape = "projects/%s/topics/%s"
533+
// Legacy style triggers
529534
case strings.HasPrefix(eventType, "providers/cloud.storage/eventTypes/"):
530535
shape = "projects/%s/buckets/%s"
531536
case strings.HasPrefix(eventType, "providers/cloud.pubsub/eventTypes/"):

google/resource_cloudfunctions_function_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ resource "google_cloudfunctions_function" "function" {
473473
timeout = 61
474474
entry_point = "helloGCS"
475475
event_trigger {
476-
event_type = "providers/cloud.storage/eventTypes/object.change"
476+
event_type = "google.storage.object.finalize"
477477
resource = "${google_storage_bucket.bucket.name}"
478478
failure_policy {
479479
retry = true
@@ -503,7 +503,7 @@ resource "google_cloudfunctions_function" "function" {
503503
timeout = 61
504504
entry_point = "helloGCS"
505505
event_trigger {
506-
event_type = "providers/cloud.storage/eventTypes/object.change"
506+
event_type = "google.storage.object.finalize"
507507
resource = "${google_storage_bucket.bucket.name}"
508508
}
509509
}`, bucketName, zipFilePath, functionName)

website/docs/r/cloudfunctions_function.html.markdown

+5-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ The following arguments are supported:
7676

7777
The `event_trigger` block supports:
7878

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

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

0 commit comments

Comments
 (0)