Home > Mobile >  Permanently change cloud function region
Permanently change cloud function region

Time:07-01

I know you can change the region of a function using the below method. Just wondering if there is a way to permanently set this to all functions so I dont have to do this to each function.

exports.myStorageFunction = functions
    .region('europe-west1')
    .storage
    .object()
    .onFinalize((object) => {
      // ...
    }); ```

CodePudding user response:

One could improve it a little bit by defining an array and use that for all functions. But otherwise than that, there is no other way to my knowledge.

const regionArr = ["europe-west3"];

exports.myFunction = functions.region(...regionArr).https.onCall(async (data, context) => {
  ...
});

CodePudding user response:

Because of the chaining builder pattern, you can do this:

const euFunctions = functions.region('europe-west1');

exports.myFunction = euFunctions.storage.object().onFinalize(...);

and it will do what you expect!

  • Related