Unable to deploy a firebase cloud function due to permission error

Viewed 11285

I was trying to deploy my first firebase cloud function using firebase cli but I encountered an error instead :

C:\Users\Anurag Tripathi\Desktop\firebasecloudfunction> firebase deploy --only functions

Error: Missing permissions required for functions deploy. You must have permission iam.serviceAccounts.ActAs on service account  project_number@appspot.gserviceaccount.com.

To address this error, ask a project Owner to assign your account the "Service Account User" role from this URL: 
        https://console.cloud.google.com/iam-admin/iam?project=project_number

I tried to solve the problem by following the instruction but didn't get any success . Please help.

Edit : I have abandoned the project :( , so I really can't test the answers. Thanks all for the answers and comments. I will accept the most upvoted answer.

6 Answers

As specified in the docs, apart from the Service Account User role, you should assign the Cloud Functions Admin role to the Service Account that you are using to deploy the functions

It turned out I had the wrong project name in the .firebaserc file. After changing the name to the correct google cloud project name it worked.

This is what worked for me. First run firebase login:list to find out if the account logged into firebase cli is the same account authorized in your Google Cloud Console. If not, run firebase logout <email> then firebase login, then deploy again.

firebase projects:list

If the current Firebase account doesn't have your project, you have to logout first.

firebase logout  
firebase login
firebase projects:list

enter image description here

firebase use <project ID>

So for example,

firebase use stripesample1


firebase projects:list

enter image description here

firebase deploy --only functions

I was having same issue, I just did firebase logout and firebase login and issue resolved

I had this issue with a co-worker who inherited the Firebase Admin role from the Organization the project belongs to.

I confirmed he had inherited the role but not all the same permissions as when you assign the role manually from Firebase Console -> Users and Permissions.

So, I could have followed the instructions in the link shown in the error log. But I thought it was safer to just re-assign the Firebase Admin role from firebase console. That solved the issue.

Related