Last active
January 10, 2020 07:18
-
-
Save PrashantBhatasana/5ec106feca1bb7489ada99e260d97f4d to your computer and use it in GitHub Desktop.
This is lambda function with javascript language that stop ec2 instence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// StopEC2Instance | |
const AWS = require('aws-sdk'); | |
exports.handler = (event, context, callback) => { | |
const ec2 = new AWS.EC2({ region: event.instanceRegion }); | |
ec2.stopInstances({ InstanceIds: [event.instanceId] }).promise() | |
.then(() => callback(null, `Successfully stopped ${event.instanceId}`)) | |
.catch(err => callback(err)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment