英文:
Reading Google Cloud Run mounted secret
问题
从我的理解来看,我应该能够将一个秘密文件挂载到Google Cloud Run服务,并且以后能够读取这个文件。然而,我一直收到一个错误:[Error: EISDIR: illegal operation on a directory, read]。我已经尝试过将服务帐户更改为具有Secret Manager Secret Accessor权限,但这也没有起作用。
有没有关于如何解决这个问题的指点?
我是如何处理这个问题的示例:
在Google Cloud Run服务设置中:将Secrets挂载路径设置为"/run/secrets/mySecret"。
在具有秘密路径的配置文件中:
{
mySecretPath: "/run/secrets/mySecret"
}
文件读取函数:
import {readFile} from 'fs/promise';
async function readMySecret(path) {
return await readFile(path, {
encoding: "utf8"
});
}
英文:
From my understanding, I should be able to mount a secret file to a Google Cloud Run service and be able to read the file later on. However, I keep getting an error: [Error: EISDIR: illegal operation on a directory, read]. I've already tried changing the service account to have the Secret Manager Secret Accessor permission, but that didn't work either
Any pointers for how I could solve this?
Example of how I'm going about this:
<< in Google Cloud Run Service setup: set Secrets mount path to "/run/secrets/mySecret"
<< in config file that has path to secret
{
mySecretPath: "/run/secrets/mySecret"
}
<< file reading function
import {readFile} from 'fs/promise'
async function readMySecret(path) {
return await readFile(path, {
encoding: "utf8"
}
}
答案1
得分: 1
根据您的设置,挂载路径是一个目录。其中包含每个版本的文件。请尝试阅读 /run/secrets/mySecret/latest
。
英文:
The way you've set it up, the mount path is a directory. There are files within it for each version. Try reading /run/secrets/mySecret/latest
intead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论