Skip to content

Instantly share code, notes, and snippets.

@juyal-ahmed
Created September 11, 2015 12:27
Show Gist options
  • Save juyal-ahmed/60cf11569dfc4080019f to your computer and use it in GitHub Desktop.
Save juyal-ahmed/60cf11569dfc4080019f to your computer and use it in GitHub Desktop.
Using DynamoDB with Node.js, Express.js
var aws_router = require('./routes/aws');
app.use('/aws', aws_router);
//npm install aws-sdk
//visit http://localhost:3000/aws/table-list
var express = require('express');
var router = express.Router();
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./config.json');
AWS.config.apiVersions = {
//dynamodb: '2011-12-05',
//ec2: '2013-02-01',
dynamodb: 'latest'
}
var db = new AWS.DynamoDB();
router.get('/table-list', function(req, res, next) {
db.listTables(function(err, data) {
console.log(data.TableNames);
});
res.send('AWS - See the console plz.');
});
module.exports = router;
{ "accessKeyId": "xxx", "secretAccessKey": "xxx", "region": "us-east-1" }
@fortheworld2017
Copy link

Great help :)

@moonseoklee
Copy link

Good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment