I have a question about Firebase Functions V2, with regards to how to include Google Secrets Manager into the document trigger function.
I know how to do it with OnRequest, the below works fine.
exports.myWebhook = onRequest({secrets: [MY_WEBHOOK_SECRET, MY_TEST_SECRET_KEY]}, async (req, res) => {
const safe = STRIPE_TEST_SECRET_KEY.value();
}
However I can't seem to get it to work with onDocumentCreated...
exports.myUpdate = onDocumentCreated("/orders/{documentId}", async (event ) => {
const myAPIKey = MY_OTHER_API.value()
}
Any time I place {secrets: [MY_OTHER_API]} anywhere in this function, it creates an error. If I exclude it then the API key value is just blank.
Any help would be appreciated. Thanks.
Tried placing {secrets: [MY_OTHER_API_KEY]} into the function to allow it access to the Google Secret value.
Per the API reference, the first parameter is either a document path or a firestore.DocumentOptions object (which extends GlobalOptions where secrets is defined):
exports.myUpdate = onDocumentCreated(
{
document: "/orders/{documentId}",
secrets: [MY_OTHER_API]
},
async (event) => {
const myAPIKey = MY_OTHER_API.value()
// other steps
}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With