Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass parameterized config value to functions.storage.bucket(<param>).object().onFinalize #1413

Open
indicava opened this issue Jun 4, 2023 · 8 comments

Comments

@indicava
Copy link

indicava commented Jun 4, 2023

Related issues

[REQUIRED] Version info

node: v16.19.1

firebase-functions: 4.4.0

firebase-tools: 12.3.0

firebase-admin: 11.9.0

[REQUIRED] Test case

create an .env file with these contents:

DEFAULT_STORAGEBUCKET=img.mydomain.com

Then create an index.js file with this function definition:


import functions from "firebase-functions"
import { defineString } from "firebase-functions/params"
const defaultBucket = defineString("DEFAULT_STORAGEBUCKET")

export const resizeImages = functions.storage.bucket(defaultBucket).object().onFinalize(async (object) => {
functions.logger.info(`defaultBucket.value() = ${defaultBucket.value()}`)
})

[REQUIRED] Steps to reproduce

run "firebase emulators:start" or "firebase deploy"

[REQUIRED] Expected behavior

Expected behavior is Storage triggered cloud function for the bucket named "img.mydomain.com"

[REQUIRED] Actual behavior

Actual behavior is I am getting this error message:

functions: Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: Error: Invalid bucket name params.DEFAULT_STORAGEBUCKET

Were you able to successfully deploy your functions?

No I was unable to deploy

@taeold
Copy link
Contributor

taeold commented Jul 6, 2023

Hi @indicava. Thanks for raising the issue.

We don't support parametrizing storage buckets using params yet. Params only work on configuration options like timeouts and memory for now. Sorry for the confusion!

@indicava
Copy link
Author

indicava commented Jul 6, 2023

Hi @indicava. Thanks for raising the issue.

We don't support parametrizing storage buckets using params yet. Params only work on configuration options like timeouts and memory for now. Sorry for the confusion!

Thanks for the update.

So do you have any suggestion on how to approach this issue when I am managing several environments with different bucket names using the same codebase?

@zallesov
Copy link

Came across the same problem.
I do not see a solution here. How could I subscribe to different buckets for dev and prd environments? There seem to be no way to provide deployment time params?

@raf-a
Copy link

raf-a commented Jul 14, 2023

Hi
I encountered the same problem. I found a solution using the environment variable process.env.GCLOUD_PROJECT.

@indicava
Copy link
Author

indicava commented Jul 14, 2023

Hi

I encountered the same problem. I found a solution using the environment variable process.env.GCLOUD_PROJECT.

Hi,

Could you elaborate a little more on how you use that environment variable to parameterize bucket names?

Maybe post/link some sample code?

Thanks!

@markglibres
Copy link

@taeold any update on this feature?

@amankr
Copy link

amankr commented Aug 7, 2023

I am also looking for this feature. It seems very important for managing buckets in multiple environment.
currently I have to change names manually while deploying to different environments, which is very inconvenient.
I hope this is picked up soon .
issue also mentioned here -> #1369

@nickesk
Copy link

nickesk commented Dec 11, 2023

This is a bug IMO. We cannot use firebase function params as the documentation instructs us to if these basic top-level methods don't work with Params, and there is no published workaround. Will the Firebase team please prioritize this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants