Skip to content

Instantly share code, notes, and snippets.

@PrashantBhatasana
Last active January 10, 2020 07:19
Show Gist options
  • Save PrashantBhatasana/0b7e0a6eb93680dff5a131845f137733 to your computer and use it in GitHub Desktop.
Save PrashantBhatasana/0b7e0a6eb93680dff5a131845f137733 to your computer and use it in GitHub Desktop.
This is lambda function with javascript language that start ec2 instence.
// StartEC2Instance
const AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const ec2 = new AWS.EC2({ region: event.instanceRegion });
ec2.startInstances({ InstanceIds: [event.instanceId] }).promise()
.then(() => callback(null, `Successfully started ${event.instanceId}`))
.catch(err => callback(err));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment