Search code examples
google-cloud-functionsgoogle-cloud-storagegcloud

gcloud functions deploy for multiple storage triggers?


How do I deploy a function that could respond to multiple GCS events? Speficially, I would like my function to respond to finalize and delete events. I tried the following but apparently I can't use wildcards (also tried comma-separated --trigger-event):

  gcloud functions deploy myfunc \
    --region europe-north1 \
    --project "myproj" \
    --gen2 \
    --runtime python311 \
    --trigger-event-filters="type=google.storage.object.*,bucket=mybucket" \
    --source "mydir" \
    --entry-point "myfunc" \
    --timeout 100s

Any idea how to do it?


Solution

  • It doesn't seem to be possible. Stated in the official documentation:

    You specify triggers as part of function deployment. You cannot bind the same function to more than one trigger at a time, but you can have the same event cause multiple functions to execute by deploying multiple functions with the same trigger settings.