How to Properly Implement Secret Manager in Firebase Cloud Functions?

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?

Answer №1

My apologies everyone.
It seems that I made an error in the following code snippet:

const hidden = {
  timeoutSeconds: 120,
  memory: "1GB",
  secrets: ["SECRET_NAME"], // Remember to use 'secrets' instead of 'secret'
  minInstances: 0,
};
https://i.sstatic.net/VXFOW.jpg

Thanks a lot, @MichaelBleigh.
The issue has been resolved now.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ionic app encounters issue fetching local JSON data

I have been working on my Ionic application and I encountered an issue when trying to load local JSON data into it. I set up a http.get in my javascript to retrieve the data, but for some reason it's not showing up in the application. It seems like th ...

How can one HTML form be used to request a unique identifier from the user, retrieve a record from the database, parse it into JSON format, and then populate an HTML page form using the

As someone who isn't an expert in any specific coding language, I have a knack for piecing things together to make them work. However, my current challenge is stretching my technical abilities a bit too far. Here's what I'm trying to achieve ...

Refreshing a page in MVC after making an Ajax call to the controller

In my controller, I have the following code: public async Task < ViewResult > Favourites(string ids) { // API call to fetch book data if (data != null) { var bookList = JsonConvert.DeserializeObject < Book[] > (data); ...

Discover how to determine the direction of a div element when utilizing the dir="auto" attribute in HTML5 with JavaScript

I'm experiencing an issue with a div that has the dir attribute set to auto. My goal is to retrieve the rendered direction using javascript After attempting div.dir, I only receive the 'auto' value. Is there a method available to detect if ...

Display radio buttons depending on the selections made in the dropdown menu

I currently have a select box that displays another select box when the options change. Everything is working fine, but I would like to replace the second select box with radio buttons instead. Can anyone assist me with this? .sub{display:none;} <sc ...

What is the best way to handle an API that consistently returns identical values but varying responses?

(Apologies if the title is unclear, I struggled to phrase it accurately) I am attempting to retrieve a response from an API, however, the API is returning multiple responses with the same name. Example of a response: { "xuid": 2535436668322645, " ...

Unpack the zipped file into the designated directory

I have a node application with Express, and I am sending requests from the client using tools like Postman. I need to extract a file from the request (req) and save it to my local folder. How can I achieve this? I came across some open-source solutions, b ...

Create line items using the quantity code as a reference

I need help implementing a feature that dynamically adds line items based on user input in a quantity text box. For example, if the user enters a quantity of 2, the page should display: Text line for item 1 Text line for item 2 Here is the code snippet ...

Using a for-loop to add HTML Ids sequentially

I'm a beginner in JavaScript and HTML, and I've been working on reading my JSON file and appending it to various HTML IDs. I was curious if there is a more efficient way of doing this using a for-loop? for(let i=0; i<5; i++){ $(`#vid${i ...

Invoke a series of functions sequentially, with each function containing an asynchronous operation within it

Is it possible to run the function a() after the function b(), even if b() has an asynchronous function c() embedded within it? A() { } B() { //do sometihng c(); //async function //do something } I am looking for a way to execute A() onl ...

Angular 2/JS - Date expression functions exclusively in the Chrome browser

Today, I decided to test my app using my FireFox browser instead of Chrome like usual, and I was surprised to find that my app isn't functioning properly. After some investigation, I discovered that the code snippet below is causing the issue by disp ...

Incorporating a TypeScript module into a JavaScript module within a React application

I'm encountering an issue with my React app that was created using create-react-app. I recently added a Typescript module to the project, which is necessary for functionality reasons. Although it will remain in Typescript, I made sure to install all t ...

Having trouble parsing dates in Javascript?

let date = new Date("2017-09-12T12:00:00"); console.log(date.getUTCMonth()); Surprisingly, the code logs 08 instead of 09, even though year, day, hour, and minute are parsed correctly. What could be causing this discrepancy? Is there a way to extract 09 ...

How to disable the next button in jQuery when a radio button is not checked, specifically for the first element

On my website, I have a series of questions with radio button answers. I want the user to only proceed to the next question once they have selected a radio button for the current question. Below is the code I have implemented: $('div.question' ...

Is it possible to utilize the output of a function nested within a method in a different method?

I am currently facing a challenge with my constructor function. It is supposed to return several methods, but I'm having trouble using the value from this section of code: var info = JSON.parse(xhr.responseText); Specifically, I can't figure ou ...

Javascript - accessing a local file (located in the same directory as the HTML file, not an uploaded file)

I have been attempting to find a solution, but have had no success. Is there a way to read a file using JavaScript or HTML? I have a text file named "sample.txt" with some information in it. This file is located in the same folder as the HTML file that con ...

Angular2 drag and drop feature becomes functional only after eliminating an irrelevant section from the template

Currently, I am harnessing the power of Angular2 to incorporate drag and drop functionalities. Specifically, my goal is to enable the movement of "windows" within different "sessions", with each window containing a set of bookmarks. Upon testing, I have o ...

I created a countdown function, but why isn't it producing any results?

Hey there! Below is my HTML code where I'm trying to implement a countdown function using AngularJS. var app = angular.module('myCountDown', []); app.controller("Countdown",function($scope){ $scope.start = function(){ var temp = $scope ...

Stop alertify.js logging from the code

I've implemented a persistent log in my project using the alertify.js library, which cannot be hidden by clicking on it. var log = alertify.closeLogOnClick(false).delay(0).log("Hello world!"); Is there a way to programmatically close this newly crea ...

Having difficulty retrieving JSON data from a different domain with Ajax calls

Trying to use JSONP to retrieve JSON from a different domain that utilizes Spring. I have implemented JsonpControllerAdvice: @ControllerAdvice public class JsonpControllerAdvice extends AbstractJsonpResponseBodyAdvice { public JsonpControllerAdvice( ...