I am upgrading my cloud functions on firebase from the first generation to the secondI use defineSecret to get a secret I have created on Google cloud, I need to deploy the functions, but the process doe not complete and givees me this error:
Error: Cannot access the value of secret “private_key” during function deployment. Secret values are only available at runtime.
this is the code of my function:
import * as admin from "firebase-admin";
import {defineSecret, defineString} from "firebase-functions/params";
const clientEmail = defineString("client-email");
const privateKey= defineSecret("private_key");
const projectId = defineString("project_key");
admin.initializeApp({
credential: admin.credential.cert({
privateKey: privateKey.value().replace(/\n/g, "n"),
projectId: projectId.value(),
clientEmail: clientEmail.value(),
}),
databaseURL: "myUrl",
});
const db = admin.firestore();
const realtime = admin.database();
export {admin, db, realtime};
what the error says is obvious, but I do not know what is wrong with my code; thanks in advance