Skip to content

Instantly share code, notes, and snippets.

@thomasmichaelwallace
Created April 30, 2019 16:40
Show Gist options
  • Save thomasmichaelwallace/88fbdbc8ef63d1307c73d53def8f180b to your computer and use it in GitHub Desktop.
Save thomasmichaelwallace/88fbdbc8ef63d1307c73d53def8f180b to your computer and use it in GitHub Desktop.
squirreldex: config
const AWS = require('aws-sdk');
const lambda = new AWS.lambda();
async function updateSotd(sotd) {
// pick one of the 1000 squirrels at random:
const id = Math.floor(Math.random() * 1000);
// build an environment with the new SD_SOTD value:
const Variables = { SD_SOTD: sotd };
const params = {
// required:
FunctionName: 'squirreldex',
// optional, only what needs updating,
Environment: { Variables },
};
// and redeploy with the new squirrel of the day configuration:
return lambda
.updateFunctionConfiguration(params).promise();
}
module.exports = { updateSotd };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment