Reading Google Cloud Run mounted secret

huangapple go评论54阅读模式
英文:

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: &quot;/run/secrets/mySecret&quot;
}

<< file reading function

import {readFile} from &#39;fs/promise&#39;
async function readMySecret(path) {
  return await readFile(path, {
     encoding: &quot;utf8&quot;
   }
}

答案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.

huangapple
  • 本文由 发表于 2023年3月1日 09:50:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75598897.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定