4

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?

1 Answer 1

8

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"
Sign up to request clarification or add additional context in comments.

2 Comments

@songololo Probably not - an understanding of your shell is typically implied. Not all shells work the same, and it would be difficult to document the behavior of each possible shell in each possible environment.
I think the reason this is potentially confusing is because (default) has relevance to the gcloud / GCP context -- presumably to hook the function against the correct default database? -- and is therefore not intuitively explanatory in the user's own shell context. So when hitting the error with gcloud cli there is potential for the line of thought that there is a problem, e.g. typo in the docs per original question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.