Skip to content

Instantly share code, notes, and snippets.

@AyemunHossain
Created May 3, 2023 07:36
Show Gist options
  • Save AyemunHossain/4be43156c7961e0263e349e04a47989d to your computer and use it in GitHub Desktop.
Save AyemunHossain/4be43156c7961e0263e349e04a47989d to your computer and use it in GitHub Desktop.
Access Firebase From AWS Lambda Function
'use strict';
var firebase = require("firebase");
exports.handler = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false; //<---Important
var config = {
apiKey: "<<apikey>>",
authDomain: "<<app_id>>.firebaseapp.com",
databaseURL: "https://<<app_id>>.firebaseio.com",
storageBucket: "<<app_id>>.appspot.com",
};
if(firebase.apps.length == 0) { // <---Important!!! In lambda, it will cause double initialization.
firebase.initializeApp(config);
}
...
<Your Logic here...>
...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment