22

I have created a service account in order to deploy a project to google app engine.

The service account I have created has these two roles:

  1. App Engine -> App Engine Deployer
  2. Storage -> Storage Object Admin

I downloaded the json key file, and then run these commands:

gcloud auth activate-service-account --key-file key.json
gcloud -q app deploy app_deploy.yaml --version 1.0 --promote

I got this error message:

ERROR: (gcloud.app.deploy) Error Response: [403] Operation not allowed

Details: [
  [
    {
      "@type": "type.googleapis.com/google.rpc.ResourceInfo",
      "description": "The \"appengine.applications.get\" permission is required.",
      "resourceType": "gae.api"
    }
  ]
]

What role did I miss to add?

Anthony Kong
  • 37,791
  • 46
  • 172
  • 304

5 Answers5

13

As of January 2020, the documentation for App Engine Roles states:

Note: The App Engine Deployer (roles/appengine.deployer) role alone grants adequate permission to deploy using the App Engine Admin API. To use other App Engine tooling, like gcloud commands, you must also have the Compute Storage Admin (roles/compute.storageAdmin) and Cloud Build Editor (cloudbuild.builds.editor) roles.

However, this is not completely true:

  1. The cloudbuild.builds.editor is not sufficient (I suspect an error in the doc here). Indeed, the CLI apparently needs the storage.objects.list permission which is provided by cloudbuild.builds.builder.
  2. After deployment, you'll get an error because you don't have permission to change traffic splits. Thus, you need roles/appengine.serviceAdmin.

So, here is the roles list that worked for me:

  • roles/appengine.deployer
  • roles/appengine.serviceAdmin
  • roles/compute.storageAdmin
  • roles/cloudbuild.builds.builder
frankie567
  • 1,703
  • 12
  • 20
  • 3
    This works, except I had to do Cloud Build Service Account instead of Cloud Build Builds Builder. Also, the storage admin role only needs to be added to the staging bucket and doesn't need to be for the whole project. – Gavin Haynes Jun 01 '21 at 02:47
11

It works if I replace the role App Engine -> App Engine Deployer with App Engine -> App Engine Admin.

No idea why Deployer will not be sufficient for app deployment.

Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
  • Also might be relevant: https://cloud.google.com/solutions/continuous-delivery-bitbucket-app-engine – Eyal Levin Apr 17 '18 at 10:54
  • I'm not having any luck `App Engine Admin` even, `Project Owner` works but anything less and nothing. – El Yobo Jan 23 '19 at 05:20
  • 2
    To date, the following combo did the trick for me: `App Engine Deployer`, `App Engine Service Admin` and `Cloud Build Service Account`. Hope this helps! – Christophe Deliens May 22 '19 at 18:07
  • I think you should turn it into an answer :-) – Anthony Kong May 22 '19 at 21:27
  • 1
    Christophe Deliens is right and the permission he mentioned is the least privilege. If you use app engine admin only it can deploy if you use, gcloud -q app deploy app.yaml --no-promote (with no-promote flag). But if you need to promote to default or any other service you need that permission. – Khalid Mar 25 '20 at 23:50
3

These roles worked for me. I'm using gcloud to deploy from AppVeyor.

  • App Engine Deployer
  • App Engine Service Admin
  • Cloud Build Service Account
  • Service Account User

Reference: https://github.com/google-github-actions/setup-gcloud/issues/191#issuecomment-706039046

Kevin Aung
  • 803
  • 6
  • 12
1

I'm still parsing all of the various docs about this myself, but I stumbled upon this list of predefined GAE roles, complete with the definition of the permissions they had. "Deployer" seems like kind of a misnomer...they maybe should have called it "NewDeployer" or something like that. Hope this helps!

EDIT - here's also the App Engine-specific list of roles.

Cheers! inger

ingernet
  • 1,342
  • 2
  • 12
  • 29
0

You don't need to grant Admin role for Storage.

You should only need grant following roles for service account:

  • App Engine Deployer
  • Storage Object Creator for only bucket staging.<project-id>.appspot.com
  • Storage Object Viewer for only bucket staging.<project-id>.appspot.com

You may got some error because service account do not have permission to change traffic to new version (you have just deployed). But deploy was successful & you can migrate to new version from console.

Following is message from my case.

[INFO] GCLOUD: ERROR: (gcloud.app.deploy) Your deployment has succeeded, but promoting the new version to default failed. You may not have permissions to change traffic splits. Changing traffic splits requires the Owner, Editor, App Engine Admin, or App Engine Service Admin role. Please contact your project owner and use the gcloud app services set-traffic --splits <version>=1 command to redirect traffic to your newly deployed version.

faithonour
  • 341
  • 2
  • 4