Home > Software design >  Why is firebase cloud functions location is US1 when my project firestore is eu3?
Why is firebase cloud functions location is US1 when my project firestore is eu3?

Time:05-05

I would like have both of firestore DB and my firebase functions to be zone EU3

Currently the firestore DB is EU3 the firebase functions is automatically deployed to US1

is there a way to change it ?

CodePudding user response:

When you create your Firebase project, you have to select the region for Cloud Firestore and/or Realtime Database. Once you have created those resources, they cannot be changed.

The region for your Cloud Functions is specified in code - by default it is us-central1. You can easily change it like this (see docs):

// Example of a Cloud Function trigger for a delete event in RTDB:
functions
  .runWith({ memory: '512MB', timeoutSeconds: 30 })
  .region('europe-west1') // this specifies the region
  .database.ref('/documents/{documentId}/users')
  .onDelete(...);

To see which regions are available, have a look here in the docs.

For your case, if you want to execute the Cloud Functions close to your database, change the region to europe-west1.

CodePudding user response:

You can change the region of your Cloud Function as explained in the doc.

For example:

exports.cloudFuctionEurope = functions
    .region('europe-west1')
    ...

Note that, at the time of writing, the two available european regions are:

  • europe-west1 (Belgium)
  • europe-west2 (London)

See the full list of available regions here.

  • Related