Skip to content

Custom Parameters while Deploying Functions or Serving Functions #1369

Open
@rohitgarg-lenskart

Description

@rohitgarg-lenskart

Currently we can't access custom parameters while deployment of functions or while serving functions locally. Only a few selected params are allowed. e.g. minInstance
Can we expect custom parameters to be added, to access while deployment or while serving.
Unlike, this issue firebase/firebase-tools#5524, where few of the values are only added to params.

Even, the most basic thing used by functions "region" is still not added, and functions.config() is deprecated, just to make things tough for the users?

If any alternatives to access custom parameters while deployment, please provide.

Use Case 1: Need to select different regions to deploy functions based on parameters.
Use Case 2: Need to select different environment and a lot of pre-deployment conditions are dependent upon the environment being selected. eg.functions.storage.bucket("bucket-name").object().onFinalize, here bucket name can be different for different projects, and the bucket name has to given while deployment itself.

Related issues

firebase/firebase-tools#5524
#1084
firebase/firebase-tools#5347

[REQUIRED] Version info

node: 18.12.1

firebase-functions: 4.2.1

firebase-tools: 11.19.0

firebase-admin: 11.5.0

[REQUIRED] Test case

const envParam = param.defineString("APP_ENV")
const bucketName = envParam.equals("dev").thenElse("dev-bucket-name", "prod-bucket-name")
//or const bucketName = envParam.equals("dev").thenElse("dev-bucket-name", "prod-bucket-name").value()

functions.storage.bucket(bucketName).object().onFinalize(async (object: ObjectMetadata) => {})

[REQUIRED] Steps to reproduce

.env file contains : APP_ENV="dev"
Build the functions.
Deploy the functions.

[REQUIRED] Expected behavior

Bucket name selected should be "prod-bucket-name", and function should be deployed successfully.

[REQUIRED] Actual behavior

Bucket name selected is "dev-bucket-name", and function is not deployed as the bucket belongs to different project and we get insufficient permissions error.

Were you able to successfully deploy your functions?

NO
Function is not deployed as the bucket belongs to different project and we get insufficient permissions error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions