title: Accessing Firebase Firestore on AWS Lambda
body: <p>I have following problem</p>
  
  <p>I am writing a lambda function which is gets a post value offer an API, than checks in firebase firestore if the value is there and than replies to the client. Simple.</p>
  
  <p>This is my code:</p>
  
  <pre><code>const serverless = require("serverless-http")
  const express = require("express")
  const app = express()
  const bodyParser = require("body-parser")
  const cors = require("cors")
  const admin = require("firebase-admin")
  var login = require("./test.json")
  
  admin.initializeApp({ credential: admin.credential.cert(login) })
  const db = admin.firestore()
  
  app.use(cors())
  app.use(bodyParser.json())
  app.use(bodyParser.urlencoded({ extended: true }))
  
  app.post("/", function(req, res) {
      let result = req.body.code.toUpperCase()
      db.collection("voucher")
          .get()
          .then(x =&gt; {
              console.log("TEST")
              console.log(x)
          })
          .catch(err =&gt; res.status(400).send({ err }))
  })
  
  module.exports.voucher = serverless(app)
  </code></pre>
  
  <p>The API works just fine, problem is connecting to the firestore, the error object I get always says:</p>
  
  <pre><code>{code: "MODULE_NOT_FOUND"}
  </code></pre>
  
  <p>I did it how it is shown in the tutorial here: 
  <a href="https://firebase.google.com/docs/firestore/quickstart" rel="nofollow noreferrer">https://firebase.google.com/docs/firestore/quickstart</a></p>
  
  <p>But it does not seem to work at all.</p>
  
  <p>I downloaded the correct credentials, actually I gave myself admin access to everything. But still it does not work.</p>
  
  <p>You guys have any suggestions?</p>