【问题标题】:Deploy firebase function with vpcConnector使用 vpcConnector 部署 firebase 功能
【发布时间】:2021-01-07 19:47:02
【问题描述】:

最新版本的 firebase (https://github.com/firebase/firebase-functions/releases/tag/v3.11.0) 允许我们为要使用的函数指定 VPC 连接器。

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'});
  }
})

使用 firebase 工具 CLI firebase deploy --only functions:redis 部署该功能后,我没有看到正在创建的 vpc 连接器:gcp-function-after-deployment

除了使用将采用 vpcConnector 的 gcloud 之外,还有其他部署 firebase 功能的方法吗?

【问题讨论】:

  • 如果 Firebase CLI 未按您预期的方式运行,请在 GitHub 上提交问题以及有关如何重现问题的完整说明github.com/firebase/firebase-tools
  • 看来我需要先将VPC连接器添加到GCP中的云功能
  • 除了firebase-functions,您还需要确保您使用的是最新版本的 Firebase CLI。最近才添加对vpcConnector 的支持。

标签: firebase google-cloud-functions firebase-cli


【解决方案1】:

使用此新功能部署 Firebase 函数不会创建 VPC 连接器,它仅允许您通过将新配置添加到函数本身来使用 GCP 中现有的 VPC 连接器。

因此,为了使其正常工作,您需要首先使用this documentation 中演示的说明在 GCP 中创建 VPC 连接器。

【讨论】:

    猜你喜欢
    • 2017-08-17
    • 1970-01-01
    • 2019-02-05
    • 2017-11-15
    • 2021-12-29
    • 1970-01-01
    • 2017-08-18
    • 2021-12-01
    • 1970-01-01
    相关资源
    最近更新 更多