Firebase CLI suddenly ignoring environment variables on Functions deployment

Viewed 176

I have a Firebase code project with Functions meant to be deployed to multiple Firebase projects over multiple regions.

I used to set the deployment region like this:

return functions
        .region(process.env.REGION)
        // ...

and used this command to deploy:

$ REGION=us-central1 firebase deploy --only functions

it worked like a charm until recently. Now it seems to completely ignore REGION=us-central1 even if I export it before I run firebase deploy.

EDIT 2022-06-13 - Possible solution

I changed the code to dump the contents of process.env to a file during deployment. This is what I got:

{
  "FIREBASE_CONFIG": "{\"projectId\":\"REDACTED\",\"storageBucket\":\"REDACTED.appspot.com\",\"locationId\":\"us-central\"}",
  "GCLOUD_PROJECT": "REDACTED",
  "CLOUD_RUNTIME_CONFIG": "{REDACTED}",
  "__CF_USER_TEXT_ENCODING": "REDACTED"
}

so definitely is not the same list of variables I have in my local environment.

I could use the locationId from FIREBASE_CONFIG to get the target location, or CLOUD_RUNTIME_CONFIG (it contains the dump of the functions .config() object, so I could set the target there). I also believe that I could use the .env and .env.{project alias or ID} files and their contents would be available in process.env at deployment time.

As per Osvaldo López's suggestion, here are some other details:

  • Running on MacOS
  • No errors are reported
  • No recent changes to the CLI

Any input would be very welcome! Thanks.

0 Answers
Related