Reputation: 1123
By default, Firebase cloud functions are deployed to the us-central1 region, but I wanted to deploy them to the europe-west2 region.
I assumed that setting the default region via the gcloud cli would mean that if I deleted and redeployed my cloud functions, they would automatically be deployed to the default region that I specified. However that is not the case. Instead, it turns out that I need to explicitly set the region for each function in the code, like this:
export const onDocumentCreated = functions.region('europe-west2').firestore.document('/some/collection/{id}').onCreate(async (snapshot) => {
// some code
});
My question is that if specifying the default region via the gcloud cli doesn't determine what region your functions are deployed to, what is it actually used for?
The gcloud config set command just says:
Default region to use when working with Cloud Functions resources. When a --region flag is required but not provided, the command will fall back to this value, if set. To see valid choices, run gcloud beta functions regions list.
Which doesn't give context around what kinds of operations involve the --region flag or what the flag is used for.
Upvotes: 0
Views: 322
Reputation: 317760
Settings in gcloud don't affect the way the Firebase CLI works. They are completely separate tools. Setting a default region in gcloud only affects the way gcloud itself works.
The only way to set the region for functions is what you're doing right now in your code. This is covered in the documentation.
Upvotes: 0