firebase / firebase/firebase-functions
Set vpcConnector back to default, (e.g. no VPC connector) based on a defineString env var.
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 232
- Avg merge
- 20h 46m
- Merged PRs (30d)
- 15
Description
### Related issues
### [REQUIRED] Version info
**node:**
16
**firebase-functions:**
4.3.1
**firebase-tools:**
11.24.0
**firebase-admin:**
11.3.0
### [REQUIRED] Test case
I want to deploy the same function to multiple GCP projects, some with a vpcConnector and some without. Those without, I've set an env variable to "default" and would like to use this in a comparator to set the connector back to default (e.g. no connector.)
### [REQUIRED] Steps to reproduce
Given `ResetValue` is "...Special configuration type to reset configuration to platform default." I'd assume I'd be able to do...
```
import { ResetValue } from 'firebase-functions/lib/common/options';
const region = defineString('REGION');
const vpcConnector = defineString('MY_VPC_VALUE');
const vpcConnectorConfig = vpcConnector
.equals('default')
.thenElse(ResetValue, vpcConnector);
const runtimeOpts: functions.RuntimeOptions = {
timeoutSeconds: 540,
memory: '8GB',
vpcConnector: vpcConnectorConfig,
vpcConnectorEgressSettings: 'ALL_TRAFFIC'
};
export const myHttpFunc = functions
.region(region)
.runWith(runtimeOpts)
.https.onCall(async (data, context) => {
```
but
1. TS error, "Argument of type 'typeof ResetValue' is not assignable to parameter of type 'string | number | boolean | string[] | Expression'"
2. on deployment, if I cast ResetValue to any to work around the TS error, I receive an error:
> Error: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/common/options' is not defined by "exports" in .../node_modules/firebase-functions/package.json
### [REQUIRED] Expected behavior
Able to set VPC connector to default value based on setting of built-in comparators
### [REQUIRED] Actual behavior
Type not allow / function deploy failed.
### Were you able to successfully deploy your functions?
No
Contributor guide
Assessment
This issue has not been assessed yet.