Create a Knox client using ec2 instance role metadata. Great for removing credentials from github and/or chef databags
See this guide which explains how to set up and use EC2 instance roles for your app.
npm install --save knox-ec2-role
var knoxec2 = require('knox-ec2-role')
var knox = require('knox')
knoxec2.authenticate(knox, {bucket: 'my-bucket'})
.then(function(client){
var req = client.put('/test/obj.json', {
'Content-Type': 'application/json'
})
req.on('response', function(res){
if (200 == res.statusCode) {
console.log('saved to %s', req.url);
}
}
req.end(JSON.stringify({foo: 'bar'}))
})
.catch(function(e){
console.log('error fetching metadata:' + e)
});
v1.0
-
authenticate
takes knox object so caller can install any fork. e.g.knoxec2.authenticate(knox, {bucket: 'my-bucket'})