0

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.

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I see your point about them being different tools, but I'm still a little confused because the gcloud documentation about this setting (please see block quote in my question) explicitly mentions 'Cloud Functions', which suggests to me that it will affect the way Firebase cloud functions work....or are 'Cloud Functions' different to Firebase cloud functions in this context? Also, out of interest, if this "functions/region" setting doesn't change anything in Firebase, can you provide any examples of what it changes in gcloud please?
Cloud Functions for Firebase is just built on top of the core Cloud Functions product. Firebase simply adds tools and APIs independently. You can choose which tools to use. medium.com/google-developers/…

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.