Skip to content

Latest commit

 

History

History
62 lines (36 loc) · 2.06 KB

README.md

File metadata and controls

62 lines (36 loc) · 2.06 KB

Using aws lambda to notify slack trigge by S3 bucket action

In my case that using gitlab backup to S3 automatic and notify to slack after upload successfully or delete backups.

According this doc.

You will not receive event notifications from automatic deletes from lifecycle policies or from failed operations.

We can't receive the delete event from lifecycle operations.

This is main steps:

Step 1: Create S3 bucket.

If using gitlab to upload backups that need IAM account to access bucket that will generate id and key to access S3.

Step 2: Create a slack Incoming WebHook integration

Slack message formatting reference

Incoming WebHooks

Setting

Step 3: Create lambda function.

If require exteral node modules that will need upload .zip to lambda function first.

NOTE:Only select main files inside the project. Don't zip whole project.

Zip selected files

Select code type

Select upload zip file

You can use buildin test json to test out your lambda function.

Test using buildin test event

Using environment variables to store variables or secrets.

var options = {
        uri: process.env.SLACK_WEBHOOK_URI,
        method: 'POST',
        json: attachments
};

Using environment varialbes

S3 delete by maker created event example

S3 delete by expired event example

S3 create event example

Step 4: Binding lambda to S3 event.

Referece doc

S3 event

S3 event detail