【发布时间】: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