dockergoogle-cloud-platformgoogle-cloud-buildgoogle-container-registrygoogle-cloud-shell

(GCP) ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com


I'm trying to upload a docker image to GCR(Google Container Registry) with Cloud Shell but I got this error message:

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object., forbidden

This is the steps which I've done.

(1st step) I ran this command:

gcloud builds submit --tag gcr.io/my_project_id/hello_world

(2nd step) Then, I was asked whether or not enabling and retrying "API [cloudbuild.googleapis.com]" then, I put and ran "y":

Creating temporary tarball archive of 2 file(s) totalling 478 bytes before compression. Uploading tarball of [.] to [gs://my_project_id_cloudbuild/source/1642137449.192753-983fc894e2f24fa086f55fa3b56d58aa.tgz] API [cloudbuild.googleapis.com] not enabled on project [354778943856]. Would you like to enable and retry (this will take a few minutes)? (y/N)? y

(3rd step) Finally, I got this message with the error message:

Enabling service [cloudbuild.googleapis.com] on project [354778943856]... Operation "operations/acf.p2-354778943856-e99f6fd8-78ec-4cbd-94a2-07e0697d5455" finished successfully. ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object., forbidden

Even though I enabled "API [cloudbuild.googleapis.com]" by running "y", I got the error message.

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object., forbidden

Are there any ways to solve this error?


Solution

  • Did you find the message below at the end of the message of 2nd step?:

    Would you like to enable and retry (this will take a few minutes)? (y/N)? y

    As the message says, it takes a few minutes after enabling "API [cloudbuild.googleapis.com]" by running "y".

    So run the command again a few minutes after enabling "API [cloudbuild.googleapis.com]" by running "y":

    gcloud builds submit --tag gcr.io/my_project_id/hello_world
    

    Then, it will be successful:

    ID: f4478e51-557b-407d-9c30-c379ef707258 CREATE_TIME: 2022-01-14T05:22:29+00:00 DURATION: 19S SOURCE: gs://my_project_id_cloudbuild/source/1642137748.745566-d75b61b6c6bc4acb9aba900650f201b2.tgz IMAGES: gcr.io/my_project_id/hello_world(+1 more) STATUS: SUCCESS