After attempting to integrate Secret Manager with a SECRET_NAME containing a specific password into my Cloud Function using Node.js, I tried two different methods. First, I added Secret Manager through the Console and then directly through Firebase CLI. Unfortunately, both approaches resulted in an empty Secret value in the Cloud Function variable of Secret, as depicted in the image below.
https://i.sstatic.net/Von3G.png
I included the parameter runWith({secret: ["SECRET_NAME"]}) in the code snippet below.
exports.Auth = functions.runWith(secret).https.onCall(async (data, context) => {
const response = 129132;
return Promise.resolve(response);
});
const secret = {
timeoutSeconds: 120,
memory: "1GB",
secret: ["SECRET_NAME"],
minInstances: 0,
};
While following the instructions outlined in the Firebase Cloud Function documentation (https://firebase.google.com/docs/functions/configenv), I spent nearly a week trying to identify where I went wrong but came up empty-handed. Even after granting the current SECRET_NAME role "Secret Manager Secret Accessor" in Google Cloud Console, the issue remained unresolved. A similar query on this topic can be found in this stackoverflow post reference.
My main question now is whether I should manually add SECRET_NAME in the Cloud Function Console within Google Cloud Platform. If that's the case, then what purpose does the aforementioned documentation serve? Is Firebase leading us astray?