GCLOUD CLI身份验证使用GitHub代码上的服务帐户
我想对gcloud
cli从github codespaces devcontainer进行身份验证。我可以设置github代码秘密以公开google_application_credentials
,并且可以分配实际的服务帐户值(JSON Content)。
但是,gcloud
cli 期望它是通往一条途径文件。什么是最好的实践?
谢谢,
I'd like to authenticate to gcloud
CLI took from GitHub Codespaces devcontainer. I can setup GitHub Codespaces secrets to expose GOOGLE_APPLICATION_CREDENTIALS
, and I can assign it the actual service account value (JSON content).
But, the gcloud
CLI expects it to be a path to a file. What is considered a best-practice to deal with that?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这些模式是否有最佳实践,但是我发现使用a lifecycle脚本,例如
postcreateCommand
。我通常不会直接从
devcontainer.json
中直接调用此命令注意: 正常使用文件。我已经成功地将此模式用于SSH键,kubeconfigs和AWS凭证。
I’m not sure if there are best practices for these patterns yet, but I’ve found success with creating a Codespace secret that contains the text of a file and writing it to a file in the Codespace using a lifecycle script such as
postCreateCommand
.Note: I usually don’t call this command from directly within
devcontainer.json
, I create a separate bash script and execute that instead.From there you should be able to interact with the file normally. I’ve successfully used this pattern for SSH keys, kubeconfigs, and AWS credentials.
您可以在环境变量中具有服务帐户键json,例如
google_credentials
(此名称实际上是Terraform提供商使用的),然后授权GCloud Cli这样的of so:请注意,这将保存
google_credentials的内容
进入通常的位置you can have service account key JSON in environment variable like
GOOGLE_CREDENTIALS
(this name is in fact used by Terraform provider) and then authorize gcloud CLI like so:Note, this will save contents of the
GOOGLE_CREDENTIALS
into usual place under