curious lad
curious lad

Reputation: 164

Firebase having different env variables for functions

I know that I can set enviroment variable with :

firebase functions:config:set someservice.key="THE API KEY" someservice.id="THE CLIENT ID"

but what i want to do is to change value of the variable when i deploy functions to cloud(production). Basicly i want different value of key for development and production. How can i do it automatically without having to change it manualy every time.

Upvotes: 0

Views: 74

Answers (1)

Michael Bleigh
Michael Bleigh

Reputation: 26313

Cloud Functions for Firebase are already built to work this way. If you have a staging project (e.g. myapp-staging) and a production project (e.g. myapp-prod) the Firebase CLI will apply functions config to the currently active project:

# Set the value differently on each project.
firebase functions:config:set --project myapp-staging some.key="STAGING_KEY"
firebase functions:config:set --project myapp-prod some.key="PROD_KEY"

# Deploy to each project, using the values as set
firebase deploy --only functions --project myapp-staging
firebase deploy --only functions --project myapp-prod

Upvotes: 1

Related Questions