I’m new to Firebase and I’m planning to create 2 Firebase projects, 1 for test environment and 1 for production environment. I want to deploy a NextJS web app and while I understand that I can use the same codebase and link it to 2 projects, I can only see that in this doc, it’s reliant on apphosting.yaml
for environment variables and secrets, but it will be checked in git. So that means we only have 1 set of values regardless of which Firebase project we’re in.
How do I create different sets of env variables and secrets for each project? Or am I approaching this the wrong way?
I’m still in planning stage, only reading through the documents, so I don’t know how to start.
2
Answers
Google Cloud Secret Manager, which
apphosting.yaml
reads value from, can store values independently in each Firebase project. So making it possible to have different config for the same codebase.I created an apphosting.yaml and created a secret in "secret manager" named "CURRENT_ENVIRONMENT" that would have either dev or prod
apphosting.yaml
Next i ran this command on each enviroment (firebase use dev & firebase use prod) to make it available.
firebase --backend {your backend id} apphosting:secrets:grantaccess CURRENT_ENVIRONMENT