![](/img/trans.png)
[英]GCP Cloud Function not mounting latest secret from Secret Manager
[英]What is the Correct Way to Use Secret Manager in Firebase Cloud Function?
我开始使用 Node.js 添加带有 SECRET_NAME 的 Secret Manager,其中包含云 Function 中的特定密码。我尝试了两种方法。 首先,使用控制台添加 Secret Manager,然后通过 Firebase CLI 直接添加 Secret Manager。 不幸的是,这两种方式都在 Secret 的 Cloud Function 变量中给出了一个空的 Secret 值,如下图所示。
我使用参数 runWith({secret: ["SECRET_NAME"]}) 如下代码所示。
exports.Auth = functions.runWith(secret).https.onCall(async (data, context) => { const response = 129132; return Promise.resolve(response); }); const secret = { timeoutSeconds: 120, memory: "1GB", secret: ["SECRET_NAME"], minInstances: 0, };
我遵循了 Firebase Cloud Function ( https://firebase.google.com/docs/functions/config-env ) 中编写的文档。
我浪费了将近一个星期的时间来找出我哪里错了,但一无所获。 我还在 Google Cloud Console 中为当前的 SECRET_NAME 添加了一个角色“Secret Manager Secret Accessor”,但结果一无所获。 正如这个 stackoverflow 帖子参考中所写
我的问题是我应该在 Google Cloud Platform 的 Cloud Function 控制台中手动添加 SECRET_NAME 吗? 如果是这样,那么上面写的文档有什么用呢? Firebase 是想把我们引向无路可走吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.