I am migrating a 1st generation Cloud Firestore Trigger to the second generation.
However, I cannot figure out how to access Google's Secret Manager from within the second generation Cloud Trigger.
Documentation exists for accessing secrets within second generation cloud functions by making use of a defineSecret
utility which is passed into the function's dependency array. However, this approach does not work with the second generation cloud trigger as there is no options parameter to pass the dependency array.
To explain with a snippet what I am trying to do:
import { onDocumentCreated } from 'firebase-functions/v2/firestore';
import { defineSecret } from 'firebase-functions/params';
const apiKey = defineSecret('API_KEY');
const onUserCreated = onDocumentCreated(
'users/{userId}',
async (event) => {
// ๐ access apiKey secret ๐
}
);
Any help would be greatly appreciated. Thank you.