It would be great if firebase-functions supported Serverless VPC connectors, like GCP functions do.
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Please keep in mind that there should be a way to specify names of VPC Connectors for each region separately - that is, if a function is deployed to multiple regions, each should be able to use a Connector with a different name.
For anyone interested, here's a patch that can be used until the feature lands:
_Note it assumes the same name of connectors across regions and validates checksums of a file. Checksums have to be updated whenever there is an update to firebase-tools._
#!/usr/bin/env bash
# cspell:ignore cloudfunctions, shasum
# Patch `firebase-tools` package to support VPC Connector on functions.
# See: https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions/create
VPC_CONNECTOR="functions"
FILE_PATH="node_modules/firebase-tools/lib/gcp/cloudfunctions.js"
PATCHED_SHA1="96e7de86258358c0f5605f3f8dcb9ed76b99f9b7"
DATA_PATTERN="labels: options.labels,"
DATA_REPLACEMENT="labels: options.labels,vpcConnector:'${VPC_CONNECTOR}',"
MASK_PATTERN="\[\"sourceUploadUrl\", \"name\", \"labels\"\];"
MASK_REPLACEMENT="[\"sourceUploadUrl\", \"name\", \"labels\", \"vpcConnector\"];"
echo "Applying patch to firebase-tools with the VPC connector: ${VPC_CONNECTOR}"
set -x
sed \
-i.bak \
-e "s/${DATA_PATTERN}$/${DATA_REPLACEMENT}/g" \
${FILE_PATH}
sed \
-i.bak \
-e "s/${MASK_PATTERN}$/${MASK_REPLACEMENT}/g" \
${FILE_PATH}
sed -i.bak -e '$a\' ${FILE_PATH}
{ set +x; } 2>/dev/null
# The following is to ensure the monkey-patch applied to `firebase-tools` is
# not impacted by an update to the package.
echo "${PATCHED_SHA1} ${FILE_PATH}" | shasum --check --portable --status -
Hi @bjon,
Thanks for the feedback. Can you please file feature requests with support here: https://firebase.google.com/support/contact/bugs-features/
It could be something like a vpcConnectors property in runtime options.
export const test = functions
.runWith({
vpcConnectors: [
{
projectId: 'blah-blah',
region: 'us-central1',
connectorName: 'test-serverless-vpc-connector'
}
]
})
.https.onRequest((req, res) => {});
ps. already filed a feature request there.
Hi @bjon I'm closing this ticket out as we don't have any plans to work on this feature in the near future. Please file the request at https://firebase.google.com/support/contact/bugs-features/.
This feature was added in https://github.com/firebase/firebase-tools/pull/2525 and release https://github.com/firebase/firebase-tools/releases/tag/v8.9.0 :tada:
Most helpful comment
It could be something like a
vpcConnectorsproperty in runtime options.ps. already filed a feature request there.