简体   繁体   English

如何在 Cloud Function 中使用 GCP 的两个不同项目 ID

[英]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.

相关问题 GCP | 云监控 | 如何对项目进行分组以在 Cloud Monitoring 信息中心上显示? - GCP | Cloud Monitoring | How to group projects for display on Cloud Monitoring Dashboard? GCP 部署云 function 失败 - GCP deploy cloud function failed GCP Cloud Function 如何从 ServiceNow 执行或触发它? - How does GCP Cloud Function can execute or trigger it from ServiceNow? Github 对 Google Cloud Functions 的操作“Constraint constraints/gcp.resourceLocations violated for projects/GOOGLE_PROJECT_ID attempted GenerateU - Github Actions to Google Cloud Functions "Constraint constraints/gcp.resourceLocations violated for projects/GOOGLE_PROJECT_ID attempting GenerateU 如何使用基于两个collections文件的云function触发器 - How to use cloud function trigger based on two collections documents apache 光束与 gcp 云 function - apache beam with gcp cloud function 如何从 GCP Cloud Function 中的 maven 资源文件夹中读取文件? - How to read a file from maven resources folder in GCP Cloud Function? GCP如何与Oracle云对接? - How to interconnect GCP with Oracle cloud? 无法将 GCP 秘密管理器与 GCP 云功能(nodeJS)一起使用 - not able to use GCP secret-manager with GCP cloud functions(nodeJS) 部署 dotnet 云 function GCP 的问题 - problem deploying dotnet cloud function GCP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM