Skip to content

secretValue not found despite seemingly being present as expected #1785

@swantzter

Description

@swantzter

Related issues

[REQUIRED] Version info

node: 22

firebase-functions: 6.6.0 (because of firebase/firebase-tools#9600 )

firebase-tools: 14.27.0

firebase-admin: 13.6.0

[REQUIRED] Test case

import { onRequest } from 'firebase-functions/https'

const secretValue = defineSecret('functions-webhook-secret')

export const mailjetWebhook = onRequest({
  region: 'europe-west1',
  invoker: 'public',
  secrets: [secretValue],
  serviceAccount: '[email protected]',
}, async (req, res) => {
  console.log(secretValue.value())
  res.status(200).send()
})

Configure the serviceAccount with the following permissions:

data "google_secret_manager_secret" "functions_mailjet_webhook_secret" {
  secret_id = "functions-webhook-secret"
}

resource "google_service_account" "function" {
  account_id   = "function"
  display_name = "Function"
}

resource "google_secret_manager_secret_iam_member" "function_webhook_secret_accessor" {
  project   = var.project
  secret_id = data.google_secret_manager_secret.functions_webhook_secret.id
  role      = "roles/secretmanager.secretAccessor"
  member    = "serviceAccount:${google_service_account.function.email}"
}

[REQUIRED] Steps to reproduce

Deploy and trigger the function,
inspect the deployed cloudrun function and note that functions-webhook-secret: Secret:projects/project/secrets/functions-webhook-secret:1 is listed as one of the function environment variables, as expected.

[REQUIRED] Expected behavior

The secret value is logged

[REQUIRED] Actual behavior

No value found for secret parameter "functions-webhook-secret". A function can only access a secret if you include the secret in the function's dependency array.

Were you able to successfully deploy your functions?

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions