-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Version info
node: v18.14.2
firebase-functions: 4.3.1
firebase-tools: 12.4.5
firebase-admin: 11.8.0
Test case
See below.
Steps to reproduce
Not exactly sure all the factors at play here, but I'm creating a v2 Cloud Function with node 18, using the firebase deploy
command with firestore eventarc triggers.
The default compute service account in this project has been disabled, as recommended for security purposes. I have specified the serviceAccount
option, both at the individual function level and as a 'global option' to use another service account in the same project, but for some reason I still get an error complaining about the default service account not being valid. This is apparently due to the default compute account being used for the eventarc triggers.
I've granted my other service account I'm trying to use the 'Cloud Datastore User', 'Cloud Run Invoker' and 'Eventarc Event Receiver' roles.
Expected behavior
Deploy works without complaining about the default compute service account which is not referenced anywhere in my setup.
Actual behavior
When running firebase deploy --only functions
in a fresh repo setup with firebase init functions
, I get this error:
⚠ functions: HTTP Error: 400, Validation failed for trigger projects/prj-XXX/locations/nam5/triggers/mytrigger-123456: The request was invalid: invalid service account YYY-compute@developer.gserviceaccount.com provided
Despite trying to set my other service account via:
import { setGlobalOptions } from "firebase-functions/v2";
setGlobalOptions({
serviceAccount: "sa-firestore-events@prj-XXX.iam.gserviceaccount.com",
});
and
export const myFunction = onDocumentCreated({
document: "/documents/{docId}",
serviceAccount: "sa-firestore-events@prj-XXX.iam.gserviceaccount.com",
}, (event) => { ... });
For reference, this is what the returned endpoint configuration looks like for the function I'm trying to deploy:
{
availableMemoryMb: ResetValue {},
timeoutSeconds: ResetValue {},
minInstances: ResetValue {},
maxInstances: ResetValue {},
ingressSettings: ResetValue {},
concurrency: ResetValue {},
serviceAccountEmail: 'sa-firestore-events@prj-XXX.iam.gserviceaccount.com',
vpc: ResetValue {},
platform: 'gcfv2',
labels: { service: 'firestore-events' },
eventTrigger: {
eventType: 'google.cloud.firestore.document.v1.created',
eventFilters: { database: '(default)', namespace: '(default)' },
eventFilterPathPatterns: { document: 'documents/{docId}' },
retry: false
}
}
Were you able to successfully deploy your functions?
I temporarily re-enabled the default compute service account, and after doing so with no other changes to my code, the deploy command worked, and the functions were created with the service account I specified.
I can see that the Eventarc triggers were created with the default compute service account.
How can I specify a different service account to use for the Eventarc triggers?