Created
May 3, 2023 07:36
-
-
Save AyemunHossain/4be43156c7961e0263e349e04a47989d to your computer and use it in GitHub Desktop.
Access Firebase From AWS Lambda Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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