Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud function deploy not working - firestore event

I'm trying to deploy a cloud function via my local terminal. For this i use the following code:

gcloud beta functions deploy networkcheck \
  --region=europe-west1 \
  --project=project-id \
  --entry-point functionName \
  --trigger-event providers/cloud.firestore/eventTypes/document.write \
  --trigger-resource projects/project-id/databases/(default)/documents/test/test_id \
  --runtime nodejs8

This will result in the following error:

deploy.sh: line 7: syntax error near unexpected token `('
deploy.sh: line 7: `  --trigger-resource projects/project-id/databases/(default)/documents/test/test_id \'

The script executes perfectly fine when i change '(default)' to 'default or any other string'. But then the cloud function will not work, because the only id that can be used for an Firestore database is '(default)', as mentioned in this post: How to find the database id of a cloud firestore project?

Is this a bug? Or can i fix this somehow?

like image 637
Roeltm Avatar asked Jan 28 '23 10:01

Roeltm


1 Answers

Parenthesis are special characters in the bash command shell. You will need to escape them so they are taken literally, instead of being interpreted by your shell. Here, I am just putting the --trigger-resource parameter in single quotes so the parenthesis won't have a special meaning:

--trigger-resource "projects/project-id/databases/(default)/documents/test/test_id"
like image 131
Doug Stevenson Avatar answered Feb 15 '23 16:02

Doug Stevenson