Skip to content

Template for Serverless framework with AWS Lambda and Discord

License

Notifications You must be signed in to change notification settings

aarlin/discord-lambda

Repository files navigation

Template for AWS Lambda + Typescript + Cron + Discord Webhooks

When IFTTT and Zapier are not enough
Set up a cron job for posting on a Discord channel

Installation

npm install
npm i serverless -g
serverless config credentials --provider aws --key YOUR_ACCESS_KEY --secret YOUR_SECRET_KEY

Create a .env file that holds the webhook URL for Discord

DISCORD_WEBHOOK=<YOUR WEBHOOK>

Start Service

To deploy to AWS

sls deploy -v

To run locally

sls invoke local -f cron

To see the cost usage

serverless logs --function <function> --tail

Remove Service

sls remove 

Debugging

This is a sample launch.json file you should have if you are using Visual Studio Code

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug API Gateway",
            "program": "${workspaceFolder}/node_modules/serverless/bin/serverless",
            "args": [
                "offline",
                "start"
            ]
        }
    ]
}

Press F5 to start debugging

References

https://blog.shovonhasan.com/deploying-a-typescript-node-aws-lambda-function-with-serverless/

https://www.jamestharpe.com/serverless-typescript-getting-started/

https://www.rookout.com/wp-content/uploads/2018/10/The-Serverless-Debugging-Guide.pdf

serverless/serverless-plugin-typescript#109

https://www.npmjs.com/package/@hewmen/serverless-plugin-typescript

Creating Template

serverless create --template aws-nodejs-typescript
npm init
npm i serverless-offline @hewmen/serverless-plugin-typescript --save-dev

About

Template for Serverless framework with AWS Lambda and Discord

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published