Closed dsjacobsen closed 5 years ago
Hey @dsjacobsen thanks for opening :+1:
The event
event can be any event which is in turn handled by a Background Function.
According to the event
docs those could be firebase events as well.
I haven't tried it but the definition should look something like this:
firestoreEvents:
handler: firestoreEvents
events:
- event:
resource: google.firebase.foo
eventType: providers/google.firebase.foo/eventTypes/bar.baz
Hello @dsjacobsen @pmuens For triggering a function upon a Firestore document change you should write something like this in your serverless.yml file:
myFunction:
handler: myFunction
events:
- event:
eventType: providers/cloud.firestore/eventTypes/document.update
resource: projects/<project-id>/databases/(default)/documents/<path-to-document>
I have written an article on how to use Serverless Framework with Firebase triggers: https://medium.com/ponce-agtech/using-firebase-triggers-in-serverless-framework-ad99594b86fa
Hope it helps ;)
Great article @marianofino thanks for sharing it here! :)
Can Firestore Event Triggers be used with the Serverless framework?
I want to use Cloud Firestore triggers, but unsure if it’s support, and if it is, then how I correctly specify the event in the serverless.yml file?
An example of a function that should trigger event when any changes to a document happens. From here: https://firebase.google.com/docs/functions/firestore-events
Note: I am importing functions from firebase in a separate file and then importing it in my index.js.
If supported, how do I configure it in serverless.yml?