ERROR: (gcloud.beta.functions.deploy) … message=[The caller does not have permission]

前端 未结 5 1212
情歌与酒
情歌与酒 2020-12-14 20:45

I am trying to deploy code from this repo:

https://github.com/anishkny/puppeteer-on-cloud-functions

in Google Cloud Build. My cloudbuild.yaml file contents a

5条回答
  •  难免孤独
    2020-12-14 21:02

    I struggled with this too after reading quite a bit of documentation. A combination of the above answers got me on the right track. Basically, something like the following is needed:

    PROJECT=[PROJECT-NAME]
    
    NUM=$(gcloud projects describe $PROJECT --format='value(projectNumber)')
    
    gcloud iam service-accounts add-iam-policy-binding \
    ${PROJECT}@appspot.gserviceaccount.com \
    --member=serviceAccount:${NUM}@cloudbuild.gserviceaccount.com \
    --role=roles/iam.serviceAccountUser \
    --project=${PROJECT}
    
    gcloud iam service-accounts add-iam-policy-binding \
        ${PROJECT}@[INSERT_YOUR_IAM_OWNER_SERVICE_ACCOUNT_NAME].iam.gserviceaccount.com \
        --member='serviceAccount:service-${NUM}@gcf-admin-robot.iam.gserviceaccount.com' \
        --role='roles/iam.serviceAccountUser'  
    

    Also, I added the "Cloud Functions Developer" role to my @cloudbuild.gserviceaccount.com account via the IAM Console.

提交回复
热议问题