An open API service indexing awesome lists of open source software.

https://github.com/serverless-components/dashboard-notification-handler

Easily build custom integrations for Serverless Dashbaord Notifications using Serverless Components
https://github.com/serverless-components/dashboard-notification-handler

Last synced: 5 months ago
JSON representation

Easily build custom integrations for Serverless Dashbaord Notifications using Serverless Components

Awesome Lists containing this project

README

          

# serverless-notification-handler

 

Easily deploy a NodeJS or Python function for handling Serverless Insight Alert Notifications.

 

1. [Install](#1-install)
2. [Create](#2-create)
3. [Configure](#3-configure)
4. [Deploy](#4-deploy)

 

### 1. Install

```console
$ npm install -g serverless
```

### 2. Create

```console
$ mkdir notification-forwarder && cd notification-forwarder
```

The directory should look something like this:

```
|- handler.js # OR handler.py
|- serverless.yml
|- .env # your AWS api keys
```

the `.env` file should look like this

```
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX
```

The `handler.js` or `handler.py` file should contain a function to handle an alert notification event from
Serverless Insights.

```python
module.exports.alert = (notification) => {
console.log('got notification', notification);
}
```

```python
def alert(notification):
print('got notification', notification)
```

### 3. Configure

Configure your `serverless.yml` as follows:

```yml
# serverless.yml

name: notification-handler
stage: dev

notificationHandler:
component: '@serverless/notification-handler'
inputs:
code: .
handler: handler.alert
env:
FOOBAR: ${env.FOOBAR} # Optional, set any env vars for your code
```

### 4. Deploy

```console
$ serverless
```

### 5. Configure the Serverless Dashboard

Paste the ARN printed in the output of the previous step into the SNS notification configuration on
dashboard.serverless.com for your app.

 

### New to Components?

Checkout the [Serverless Components](https://github.com/serverless/components) repo for more information.