我在 GCP 中有两个项目,假设项目 A 和 B。项目 A 是新创建的,项目 B 已有两年了。当我在项目 A 中创建云函数时,它是使用默认服务帐户 (project@appspot...) 创建的。但是,当我在项目 B 上创建云函数时,使用了不存在的服务帐户。我知道它不存在,因为它没有出现在 IAM 上。
在项目A中创建的云函数可以访问数据存储,但是项目B中的相同云函数无法访问数据存储。
所以,我的问题是:
我如何知道云功能将使用哪个 Google 服务帐户?
有没有办法更改项目 B 使用的服务帐户以获得访问数据存储的云功能?
我尝试过给云功能适当的权限,但是只要是在项目B中就不行。我在这里缺少什么?
最佳答案
您似乎需要在项目 B 中检查两个不同的帐户。
首先是 Google API 服务帐户。您应该确保它存在并且具有正确的凭据才能正确使用 Cloud Functions。以下是 GCP 文档中的文档:
For administrative actions on your project during the creation, updating, or deletion of functions, the Cloud Functions service uses the Google APIs service account [email protected]. By default, this service account has the Editor role on your project. Creating, updating, and deleting functions may fail if you reduce this account's permissions.
接下来是运行时服务帐户。从您描述的问题来看,这可能是真正的问题。同样,这里是解释它的文档:
At runtime, Cloud Functions uses the service account [email protected], which has the Editor role on the project. You can change the roles of this service account to limit or extend the permissions for your running functions.
关于google-app-engine - 谷歌云功能权限问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48406271/