[英]GCP Cloud Function not mounting latest secret from Secret Manager
My Cloud Function is referencing an older version of a secret that is mounted, despite using the :latest
suffix尽管使用了:latest
后缀,My Cloud Function 正在引用已安装的旧版本的秘密
I have a Cloud Function deployed that mounts a secret when I deploy, explicitly referencing the latest version of the secret:我部署了一个云 Function,它在我部署时安装了一个秘密,明确引用了秘密的最新版本:
--set-secrets=DATABASE_URL=projects/MY_PROJECT/secrets/DATABASE_URL:latest
I see this is set up correctly in my Cloud Function console but when running the function it is referencing a past version of the secret.我看到这在我的云 Function 控制台中设置正确,但在运行 function 时它引用了过去版本的秘密。 I am logging the secret to test with process.env.DATABASE_URL
(it is a Node runtime).我正在记录秘密以使用process.env.DATABASE_URL
(它是一个 Node 运行时)进行测试。
If I redeploy the function this is fixed.如果我重新部署 function,这是固定的。 I'm confused because the docs specify that mounting the secrets and adding the :latest
suffix will use the most recent version when the function runs.我很困惑,因为文档指定安装机密并添加:latest
后缀将在 function 运行时使用最新版本。
The secret is resolved when this instance of the Cloud Function starts.当云 Function 的这个实例启动时,秘密就解决了。 If the function stays active without going to sleep it will keep the old version of the secret mounted asn an environment variable.如果 function 保持活动状态而不会休眠,它会将旧版本的秘密安装为环境变量。 If you mount the secret as a volume and read the file it will automatically update.如果您将机密作为卷安装并读取文件,它将自动更新。
Credit: John Hanley's comment图片来源:John Hanley 的评论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.