AWS Lambda setup: create Lambda function to connect Snyk to Slack
AWS Lambda functions are used to connect Snyk to Slack because these functions are an inexpensive and efficient way of running code triggered by events, for example when there is a new Snyk vulnerability.
Note: If publishing the Lambda function through API Gateway, both must be configured in the same region. You can check this on the top right of the AWS Console.
Start by creating a zip file containing the code for the function and the necessary dependencies.
Save these two code blocks as package.json and index.js
package.json (modify to fit any other dependencies needed for your code, the dependencies needed are axios and crypto)
{"name":"snyk-webhook-handler","version":"1.0.0","description":"Snyk to Slack Webhook Integration","main":"index.js","scripts": {"test":"echo \"Error: no test specified\" && exit 1" },"author":"","license":"ISC","dependencies": {"axios":"^1.1.3","crypto":"^1.0.1" }}