Can I change the env value of Hasura Cloud from the CLI? - hasura

Hasura Cloud is in use. I want to synchronize environmental variables in GitHub action at all times for this project. Is there an option to read the .env file from the CLI and apply it to Hasura Cloud?

You can call the Hasura Cloud API in your Github Action https://hasura.io/docs/latest/api-reference/cloud-api-reference/#update-env-vars

Related

Can I create and configure a GCP project + Firebase completely from the CLI or a script?

I am using gcloud + firebase cli to explore a reproducible way to create and configure a GCP + Firebase project.
I have created the GCP project using gcloud cli tool. I have then used firebase cli to run the command firebase init firestore.
Ulimately it ended up outputting...
Error: It looks like you haven't used Cloud Firestore in this project before. Go to https://console.firebase.google.com/project/my-project/firestore to create your Cloud Firestore database.
Is there a way I can "create my firestore database" using a cli tool or scripting api, instead of having to navigate to a web GUI tool and manually execute steps?
Unless Firebase do more behind the scenes, creating a Firestore instance could be as simple as this command from the GCloud CLI reference:
gcloud firestore databases create --region=us-central --project=my-project
The documentation for the entire create-provision cycle (from GCP's perspective) is here - including Terraform details (some commands may have been released since the docs were written).

FIREBASE_CONFIG environment variable in GCP Cloud Run

This page explains:
Note: The FIREBASE_CONFIG environment variable is included automatically in Cloud Functions for Firebase functions that were deployed via the Firebase CLI.
Can we get access to the same FIREBASE_CONFIG environment variable in Cloud Run environment? If yes, how?
If no, please give instructions on setting firebase-admin initializeApp and firebase initializeApp for authentication on Cloud Run.
Should we save the serviceAccount and firebase-config in our project and import them? If so, what are the best practices for doing that? When working on an open-source project, we should put these files in .gitignore. Then how should we push them to the Cloud Run environment using gcloud CLI?

Don't delete firebase cloud funtions

I'm configuring CD process on gitlab to google cloud functions (firebase).
Also i have 3 envs (development, staging and production) and i want to deploy each function with matching postfix (_development, _staging).
When i deploy functions to development, for instance, from my local machine with command
firebase deploy --only functions
it always asks me
Would you like to proceed with deletion? Selecting no will continue the rest of the deployments.
And i choose "No", because i don't want to delete existing functions with other postfixes. But on gitlab there is no possibility to enter "No" and it decides to delete all that functions as default.
Is there some solution to not delete existing functions in cloud? Probably some flag in deploy command?
The way you are managing environments is not recommended by the Firebase team. You should be using different projects to isolate the different environments as described in the documentation.
But if you absolutely can't make any changes to what you're doing, what you will have to do is call out the names of each function to deploy, as described in the documentation:
By default, the Firebase CLI deploys all of the functions inside
index.js at the same time. If your project contains more than 5
functions, we recommend that you use the --only flag with specific
function names to deploy only the functions that you've edited.
Deploying specific functions this way speeds up the deployment process
and helps you avoid running into deployment quotas. For example:
$ firebase deploy --only functions:addMessage,functions:makeUppercase
Or, you can use function groups.

How to access firebase-functions environment configuration from Cloud Run

I'm migrating a Firebase Function to Cloud Run. Everything is working as expected so far, including the Firebase Hosting link (which is great!). I'm just not sure how I should read the environment variables I've configured for this project (via https://firebase.google.com/docs/functions/config-env).
You'll have to find a different way to configure Cloud Run. You won't be able to access your environment variables set for Cloud Functions when deployed with the Firebase CLI. Those variables are only accessible for code running in Cloud Functions that uses the "firebase-functions" module.
Instead, you should set your Cloud Run environment with gcloud as documented here.

Create multiple database instances via Firebase CLI

I am looking into automating the deployment of a project that is made up of multiple functions that are triggers on multiple realtime database instances.
Using firebase deploy allows you to deploy both functions and database rules.
I have also created targets so i can deploy different rules for different database instances.
The only missing part of my automation is actually creating those different database instances via the Firebase CLI tool; Since deploying a trigger function to a specific database that doesn't exist will fail. Ideally i would like to make sure to create those database instances if they don't exist and then continue my deployment.
Is there a way to create different database instances via the CLI ?
I don't know when it was added, but this might be useful for others having the same question.
You can create a Firebase Realtime Database instance using the following CLI command:
firebase database:instances:create [instance-name]
I don't know why this isn't described in the CLI reference, but it is mentioned here: https://firebaseopensource.com/projects/firebase/firebase-tools/
You can Create realtime database instance by firebase CLI using the below command
firebase database:instances:create -P <alias_or_project_id> <DBinstanceName>
This Command work fine if you have paid plan.
For Free Plan it throw error:- FirebaseError: HTTP Error: 400, Precondition check failed.
Note : <DBinstanceName> should be alpha-numeric with hyphens.

Resources