Created
June 7, 2020 20:06
-
-
Save logemann/82c0d4b44332bb3046dbf5c1e1c14981 to your computer and use it in GitHub Desktop.
Start Stop Lambda
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
var AWS = require('aws-sdk'); | |
exports.handler = async (event) => { | |
var cloudformation = new AWS.CloudFormation(); | |
console.log(`Invoking StartStop Script with Parameter: ${event}`); | |
if (event == "startup") { | |
// ============== | |
// start the VPN | |
// ============== | |
console.log("Trying to start the VPN by creating the VPN Stack....") | |
var params = { | |
StackName: 'vpnStack', | |
TemplateBody: getVpnCfnTemplate() | |
}; | |
return cloudformation.createStack(params).promise(); | |
} else { | |
// ============== | |
// stop the VPN | |
// ============== | |
console.log("Trying to stop the VPN by destroying the VPN Stack....") | |
var params = { | |
StackName: 'vpnStack', | |
}; | |
return cloudformation.deleteStack(params).promise(); | |
} | |
}; | |
function getVpnCfnTemplate() { | |
return `{}`; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment