I started to add Secret Manager with a SECRET_NAME contains a certain password inside Cloud Function using Node.js. I tried both ways. First, adding Secret Manager using Console and another, adding Secret Manager directly through Firebase CLI. Unfortunately, both ways give an empty Secret value in Cloud Function variable of Secret as shown in picture below.
Link to picture
I used parameter runWith({secret: [“SECRET_NAME”]}) as shown in code 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,
};
I followed the documentation written in Firebase Cloud Function (https://firebase.google.com/docs/functions/config-env).
I had wasted almost a week to figure out where I got wrong and found nothing. I also added a role “Secret Manager Secret Accessor” to current SECRET_NAME in Google Cloud Console, and it gave result to nothing at all. As written in this stackoverflow post reference
My question is should I add SECRET_NAME manually in Cloud Function Console in Google Cloud Platform? If so, then what is the use of documentation written above? Is Firebase trying to lead us to nowhere?