Search code examples
amazon-web-servicesenvironment-variablesamazon-ecsgoogle-authenticationfirebase-admin

How to store GOOGLE_APPLICATION_CREDENTIALS in an AWS ECS environment on Fargate?


We have an API app that uses Firebase Admin to send messages to devices. Earlier, we used to specify the service account key using environment variable like GOOGLE_APPLICATION_CREDENTIALS="path_to_file.json". But now, since we are shifting to AWS Elastic Container Service on Fargate, I am unable to figure out how to put this file in the container for AWS ECS.

Any advice highly appreciated.

Thanks


Solution

  • Solved it by storing the service key as a JSON Stringified environment variable & using admin.credential.cert() instead of defaultAppCredentials. Refer: https://firebase.google.com/docs/reference/admin/node/admin.credential#cert