Skip to content

Instantly share code, notes, and snippets.

@logemann
Created June 7, 2020 20:06
Show Gist options
  • Save logemann/82c0d4b44332bb3046dbf5c1e1c14981 to your computer and use it in GitHub Desktop.
Save logemann/82c0d4b44332bb3046dbf5c1e1c14981 to your computer and use it in GitHub Desktop.
Start Stop Lambda
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