Deploy firebase function with vpcConnector

Viewed 389

The latest release of firebase (https://github.com/firebase/firebase-functions/releases/tag/v3.11.0) allows us to specify a VPC connector for a function to use.

export const redis = functions.runWith({
  vpcConnector: 'my-redis-connector',
  vpcConnectorEgressSettings: 'PRIVATE_RANGES_ONLY'
}).https.onRequest((req, res) => {
  const client = redisLib.createClient(REDIS_PORT, REDIS_HOST)
  
  if (client.connected === true) {
    return res.status(200).send({redis: 'found'});
  } else {
    return res.status(404).send({ redis: 'not found'});
  }
})

After deploying the function using the firebase tools CLI firebase deploy --only functions:redis, I don't see the vpc connecter being created: gcp-function-after-deployment

Is there a different way of deploying the firebase function, besides using the gcloud that will take the vpcConnector?

1 Answers

The deployment of Firebase Function with this new feature does not create a VPC Connector, it only allows you to use an already existing VPC Connector in GCP by adding the new configuration to the function itself.

So in order to make it work you need to first create the VPC Connector in GCP using the instructions demonstrated in this documentation.

Related