Skip to content

Instantly share code, notes, and snippets.

@raphaellondner-mongodb
Last active March 29, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raphaellondner-mongodb/ddc807b613e02b343b081ae09bdacced to your computer and use it in GitHub Desktop.
Save raphaellondner-mongodb/ddc807b613e02b343b081ae09bdacced to your computer and use it in GitHub Desktop.
mongodb-atlas-lambda-step0
'use strict'
var MongoClient = require('mongodb').MongoClient;
let atlas_connection_uri;
let cachedDb = null;
exports.handler = (event, context, callback) => {
var uri = process.env['MONGODB_ATLAS_CLUSTER_URI'];
if (atlas_connection_uri != null) {
processEvent(event, context, callback);
}
else {
atlas_connection_uri = uri;
console.log('the Atlas connection string is ' + atlas_connection_uri);
processEvent(event, context, callback);
}
};
function processEvent(event, context, callback) {
console.log('Calling MongoDB Atlas from AWS Lambda with event: ' + JSON.stringify(event));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment