Skip to content

Instantly share code, notes, and snippets.

@thomasmichaelwallace
Created April 30, 2019 16:40
Show Gist options
  • Select an option

  • Save thomasmichaelwallace/88fbdbc8ef63d1307c73d53def8f180b to your computer and use it in GitHub Desktop.

Select an option

Save thomasmichaelwallace/88fbdbc8ef63d1307c73d53def8f180b to your computer and use it in GitHub Desktop.

Revisions

  1. thomasmichaelwallace created this gist Apr 30, 2019.
    21 changes: 21 additions & 0 deletions config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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 };