Skip to content

Instantly share code, notes, and snippets.

@anuragmathur1
Created April 10, 2017 09:19
Show Gist options
  • Save anuragmathur1/d3083ec6165c41461bbaaf3f6f7b15c9 to your computer and use it in GitHub Desktop.
Save anuragmathur1/d3083ec6165c41461bbaaf3f6f7b15c9 to your computer and use it in GitHub Desktop.
nodejs Lambda function to start a EC2 instance
var AWS = require('aws-sdk');
exports.handler = function(event, context) {
var ec2 = new AWS.EC2({region: 'us-east-1'});
ec2.startInstances({InstanceIds : ['i-0114833f8ffc9151c'] },function (err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
context.done(err,data);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment