最新版本的 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 function:redis
部署该函数后,我没有看到正在创建的 vpc 连接器:gcp-function-after-deployment
除了使用使用 vpcConnector 的 gcloud 之外,还有其他方法来部署 firebase 功能吗?
最佳答案
使用此新功能部署 Firebase Function 不会创建 VPC 连接器,它仅允许您通过向函数本身添加新配置来使用 GCP 中现有的 VPC 连接器。
因此,为了使其正常工作,您需要首先使用 this documentation 中演示的说明在 GCP 中创建 VPC 连接器.
关于firebase - 使用 vpcConnector 部署 firebase 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63996944/