[英]How to use two differents projects id of GCP in Cloud Function
I have a Cloud Function, in this function I'm connecting database through secrets by GCP我有一个云 Function,在这个 function 中,我通过 GCP 秘密连接数据库
for my secrets I'm using different project id (com-project-data) For my Google Cloud Function I'm using another project id (com-project-common)对于我的秘密,我使用不同的项目 ID (com-project-data) 对于我的 Google Cloud Function 我使用另一个项目 ID (com-project-common)
Exists a conflict because each project have a different service account, then I'm asking the following question...存在冲突,因为每个项目都有不同的服务帐户,然后我问以下问题......
Can I inject two differents service accounts in my Cloud Function?我可以在我的云 Function 中注入两个不同的服务帐户吗? If this is probably,如果这可能是,
How Can I do it?我该怎么做?
A service account is one identity.服务帐户是一个身份。 Your function has its own identity.您的 function 有自己的身份。 Then, this identity should access the required resources.然后,这个身份应该访问所需的资源。
Therefore, grant the Cloud Functions service account the permission to access the resources, secret or whatever.因此,授予 Cloud Functions 服务帐户访问资源、机密或其他内容的权限。
In that concept, you can easily understand that you can't have 2 identities for the same service (Cloud Functions can't be schizophrenia!)在那个概念中,你可以很容易地理解你不能为同一个服务有 2 个身份(Cloud Functions 不能是精神分裂症!)
Of course, you can do unrecommended things, like using a service account key file for each project and have 2 authentications, but it's a terrible thing and you have to avoid this pattern.当然,你可以做一些不推荐的事情,比如为每个项目使用服务帐户密钥文件并进行 2 次身份验证,但这是一件很糟糕的事情,你必须避免这种模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.