Based on this documentation, I am attempting to utilize a Firebase Parameterized configuration directly within the region()
config for a function.
My .env
file looks like this:
LOCATION = 'australia-southeast1';
And my config
file is structured as follows:
import { defineString } from 'firebase-functions/params';
export const LOCATION = defineString('LOCATION');
Now, my goal is to incorporate that Parameterized configuration into the region()
config for my function.
First Try: I attempted to provide the param directly following the guidelines in the docs:
import * as functions from 'firebase-functions';
import { LOCATION } from './config';
const sydneyFunctions = functions.region(LOCATION); // <-- ERROR HERE
However, TypeScript throws this error:
Argument of type 'StringParam' is not assignable to parameter of type 'string'.ts(2345)
Second Try:
In an attempt to avoid the TypeScript error, I tried using LOCATION as unknown as string
to cast it explicitly as a string:
import * as functions from 'firebase-functions';
import { LOCATION } from './config';
const sydneyFunctions = functions.region(LOCATION as unknown as string);
However, deployment resulted in this error:
HTTP Error: 403, Permission denied on 'locations/'australia-southeast1';' (or it may not exist).
Third Try:
I experimented with using LOCATION.value()
like so:
import * as functions from 'firebase-functions';
import { LOCATION } from './config';
const sydneyFunctions = functions.region(LOCATION.value());
But this also led to deployment failure with a similar error message:
HTTP Error: 403, Permission denied on 'locations/' (or it may not exist)
Attempts to use LOCATION.toString()
and LOCATION.value().toString()
yielded comparable errors.
It seems that nothing I try is successful in resolving the issue.