角色决定了哪些服务和操作可供某一用户账号或服务账号使用。以下类型的角色可授予对 App Engine 的访问权限:
- 基本角色:适用于项目中的所有服务和资源,包括但不限于 App Engine。例如,具有 Editor 角色的账号可以更改 App Engine 设置以及 Cloud Storage 设置。 
- 预定义 App Engine 角色,提供对 App Engine 的精细访问权限。您的Google Cloud 项目中的每项服务都具有自己的预定义角色。例如,仅具有 App Engine Deployer 角色的账号可以部署 App Engine 应用,但无法在 Cloud Storage 中查看或创建对象。此类账号还需要具有特定的 Cloud Storage 预定义角色才能在 Cloud Storage 中创建或查看对象。 
- 自定义角色:根据您指定的权限列表提供精细访问权限。 
在处理需求不太复杂的小型项目时,您可以使用基本角色。如需实现更精细的访问权限控制,请使用预定义角色。
基本角色
基本角色适用于项目中的所有服务和资源。例如,具有 Editor 角色的账号可以更改 App Engine 设置以及 Cloud Storage 设置。
| 角色 | Google Cloud 控制台权限 | 工具权限 | 
|---|---|---|
| Owner | 如需创建 App Engine 应用,必须具有此角色。该角色拥有 Viewer 和 Editor 的所有权限,还可以查看已部署的源代码、邀请用户、更改用户角色以及删除应用。 | 如需创建 App Engine 应用,必须具有此角色。还可以部署应用代码和更新所有配置。 | 
| Editor | 该角色可以查看应用信息和修改应用设置。 | 该角色可以部署应用代码以及更新索引/队列/Cron。 | 
| Viewer | 该角色可以查看应用信息。 | 该角色可以请求日志 | 
预定义 App Engine 角色
| Role | Permissions | 
|---|---|
| App Engine Admin( Read/Write/Modify access to all application configuration and settings. To deploy new versions, a principal must have the
Service Account User
( Lowest-level resources where you can grant this role: 
 | 
 
 
 
       
 
 
 
 
 
       
 
 
       
 
 
 
 
 
 
 
 
 
 
 
 | 
| App Engine Creator( Ability to create the App Engine resource for the project. Lowest-level resources where you can grant this role: 
 | 
 
 
 | 
| App Engine Viewer( Read-only access to all application configuration and settings. Lowest-level resources where you can grant this role: 
 | 
 
 
 
 
       
 
 
 
 
 
 
 
 | 
| App Engine Code Viewer( Read-only access to all application configuration, settings, and deployed source code. Lowest-level resources where you can grant this role: 
 | 
 
 
 
 
       
 
 
 
 
 
 
 
 
 | 
| App Engine Managed VM Debug Access( Ability to read or manage v2 instances. | 
 
 
       
 
       
 
 
 
 
 
 
 | 
| App Engine Deployer( Read-only access to all application configuration and settings. To deploy new versions, you must also have the
Service Account User
( Cannot modify existing versions other than deleting versions that are not receiving traffic. Lowest-level resources where you can grant this role: 
 | 
 
 
 
 
       
 
 
 
 
 
 
 
 
 
 
 
 
 | 
| App Engine Memcache Data Admin( Can get, set, delete, and flush App Engine Memcache items. | 
 
 
 
 
 
 
 | 
| App Engine Service Admin( Read-only access to all application configuration and settings. Write access to module-level and version-level settings. Cannot deploy a new version. Lowest-level resources where you can grant this role: 
 | 
 
 
 
 
 
       
 
       
 
 
 
 
 
 
 
 | 
| App Engine Standard Environment Service Agent( Give App Engine Standard Envirnoment service account access to managed resources. Includes access to service accounts. | 
 
 
 
 
 
       
 
 
 
 
 
       
 
       
 
       
 
 
 
 
       
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
       
 
       
 
 
 
 
       
 
 
       
 
 
 
 
 
 | 
App Engine 预定义角色可为您提供更精细的访问权限控制选项。
这些角色仅提供对 App Engine 的访问权限。如果您的项目包含其他服务,例如 Cloud Storage 或 Cloud SQL,您将需要分配其他角色才能启用对其他服务的访问权限。
App Engine 预定义角色对比
下表对各个预定义 App Engine 角色所拥有的权限进行了全面比较。
| 能力 | App Engine Admin | App Engine Service Admin | App Engine Deployer | App Engine Viewer | App Engine Code Viewer | 
|---|---|---|---|---|---|
| 列出所有服务、版本和实例 | 是 | 是 | 是 | 是 | 是 | 
| 查看所有应用、服务、版本和实例设置 | 是 | 是 | 是 | 是 | 是 | 
| 查看运行时指标,例如资源使用情况、负载信息和错误信息 | 是 | 是 | 是 | 是 | 是 | 
| 查看应用源代码 | 否 | 否 | 否 | 否 | 是 | 
| 部署应用的新版本 | 有(如果您还授予了 Service Account User 角色) | 否 | 有(如果您还授予了 Service Account User 角色) | 否 | 否 | 
| 拆分或迁移流量 | 是 | 是 | 无*** | 否 | 否 | 
| 启动和停止版本 | 是 | 是 | 否 | 否 | 否 | 
| 删除版本 | 是 | 是 | 是 | 否 | 否 | 
| 删除整个服务 | 是 | 是 | 否 | 否 | 否 | 
| 使用 SSH 连接到柔性环境中的虚拟机实例 | 是 | 否 | 否 | 否 | 否 | 
| 关停实例 | 是 | 否 | 否 | 否 | 否 | 
| 停用和重新启用 App Engine 应用 | 是 | 否 | 否 | 否 | 否 | 
| 使用具有 login:admin 限制的处理程序(仅限于第一代运行时环境) | 是 | 否 | 否 | 否 | 否 | 
| 更新调度规则 | 是 | 否 | 否 | 否 | 否 | 
| 更新 DoS 设置 | 是 | 否 | 否 | 否 | 否 | 
| 更新 Cron 时间表 | 否 | 否 | 否 | 否 | 否 | 
| 更新默认 Cookie 过期时间 | 是 | 否 | 否 | 否 | 否 | 
| 更新引荐来源网址 | 是 | 否 | 否 | 否 | 否 | 
| 更新 Email API 授权发件人 | 是 | 否 | 否 | 否 | 否 | 
如需详细了解每个角色所授予的特定 IAM 权限,请参阅 Admin API 的角色部分。
建议在部署应用时使用的角色
对于仅负责部署应用新版本的账号,我们建议您授予以下角色:
- App Engine Deployer 角色 (roles/appengine.deployer)
- Service Account User 角色 ( - roles/iam.serviceAccountUser)- Service Account User 角色可让该账号在部署过程中模拟默认的 App Engine 服务账号。 
- 如果账号使用 - gcloud命令或其他 App Engine 工具进行部署,也请添加以下角色:- Storage Object Admin (roles/storage.objectAdmin)
- Cloud Build Editor (roles/cloudbuild.builds.editor)
 
- Storage Object Admin (
如需详细了解如何授予所需权限,请参阅创建用户账号。
部署与流量路由职责分离
许多组织倾向于将部署应用版本的任务与逐渐增加新创建版本流量的任务分开,并通过不同的工作职能来完成这些任务。App Engine Deployer 和 App Engine Service Admin 角色能够实现这种分离:
- App Engine Deployer 和 Service Account User 角色 - 账号只能部署新版本以及删除不再处理流量的旧版本。拥有这些角色的账号将无权为任何版本配置流量,也无权更改调度规则或身份验证网域等应用级设置。
- App Engine Service Admin 角色 - 账号无权部署应用的新版本,也无权更改应用级设置。但是,这些账号有权更改现有服务和版本的属性,包括更改可以处理流量的版本。App Engine Service Admin 角色非常适合运营/IT 部门用于逐渐增加新部署版本的流量。
预定义角色的局限性
任何 App Engine 预定义角色均不会授予以下权限:
- 查看和下载应用日志。
- 在 Google Cloud 控制台中查看 Monitoring 图表。
- 启用和停用结算功能。
- 在 Cloud Security Scanner 中运行安全扫描。
- 访问存储在 Datastore、任务队列、Cloud Search 或其他任何 Cloud Platform 存储产品中的配置或数据。