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 };