I have a Firebase/GCP project with a cloud function that installs a Firestore database hook:
index.ts
export const onCreatePost = functions.firestore.document("/posts/{id}")
.onCreate((snapshot) => {
...
});
The function triggers every time a new document is created in the Firestore collection "posts", but it fails immediately with an error. The log shows Error: 7 PERMISSION_DENIED: The principal (user or service account) lacks IAM permission "iam.serviceAccounts.actAs" for the resource "******************@gcp-sa-cloudtasks.iam.gserviceaccount.com" (or the resource may not exist). I'm not sure which principal lacks the correct permissions. I'm also not sure why it wants to access a resource seemingly related to Google Cloud Tasks. Finally, I've checked IAM settings to ensure that the service account mentioned in the log has a role that grants the permission iam.serviceAccounts.actAs (although I'm not sure that matters, as it doesn't seem that the mentioned service account is the one missing permissions).
In the Cloud Functions console, the principal ******************@gcp-sa-cloudtasks.iam.gserviceaccount.com is listed as a Cloud Functions Invoker.
What permissions do I need to grant in order for a Firestore hook to call a cloud function?