繁体   English   中英

无法将 GCP 秘密管理器与 GCP 云功能(nodeJS)一起使用

[英]not able to use GCP secret-manager with GCP cloud functions(nodeJS)

我正在尝试访问存储在 GCP 秘密管理器中的秘密。 使用以下示例代码并在使用 babel 部署其转译之前。

const { SecretManagerServiceClient } = require("@google-cloud/secret-manager");

const client = new SecretManagerServiceClient();
exports.hello = () => {
  //do something with client
};

相同的转译版本

"use strict";

var _require = require("@google-cloud/secret-manager"),
    SecretManagerServiceClient = _require.SecretManagerServiceClient;

var client = new SecretManagerServiceClient();

exports.hello = function () {//do something with client
};

但是我在秘密管理器实例化时遇到以下错误( const client = new SecretManagerServiceClient();

Detailed stack trace: Error: Node.js v10.0.0 is a minimum requirement. To learn about legacy version support visit: https://github.com/googleapis/google-cloud-node#supported-nodejs-versions
     at new GrpcClient (/srv/node_modules/@google-cloud/secret-manager/node_modules/google-gax/build/src/grpc.js:63:19)
     at new SecretManagerServiceClient (/srv/node_modules/@google-cloud/secret-manager/build/src/v1/secret_manager_service_client.js:99:25)
     at Object.<anonymous> (/srv/index.js:6:14)
     at Module._compile (module.js:653:30)
     at Object.Module._extensions..js (module.js:664:10)
     at Module.load (module.js:566:32)
     at tryModuleLoad (module.js:506:12)
     at Function.Module._load (module.js:498:3)
     at Module.require (module.js:597:17)
     at require (internal/module.js:11:18)

当我在我的本地机器上尝试时,我可以使用同一个库访问/修改秘密。 但是它似乎不适用于 CF。

CF 服务帐户可以访问 secret-manager。

任何帮助,将不胜感激。 提前致谢。

正如@sethvargo 所指出的,在部署期间指定运行时解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM