Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-offline-sns

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-offline-sns

Serverless plugin to run a local SNS server and call lambdas with events notifications.

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
decreased by-4.51%
Maintainers
1
Weekly downloads
 
Created
Source

serverless-offline-sns

A serverless plugin to listen to offline SNS and call lambda fns with events.

serverless Build Status npm version PRs Welcome License: MIT

Docs

Prerequisites

This plugin provides an SNS server configured automatically without you specifying an endpoint.

If you'd rather use your own endpoint, e.g. from your AWS account or a localstack SNS server endpoint, you can put it in the custom config. See below for details.

Installation

Install the plugin

npm install serverless-offline-sns --save

Let serverless know about the plugin

plugins:
  - serverless-offline-sns

Configure the plugin with your offline SNS endpoint and a free port the plugin can use.

custom:
  serverless-offline-sns:
    port: 4002 # a free port for the sns server to run on
    debug: false
    sns-endpoint: http://127.0.0.1:4567 # Optional. Only if you want to use a custom endpoint

If you are using the serverless-offline plugin serverless-offline-sns will start automatically. If you are not using this plugin you can run the following command instead:

serverless offline-sns start

Configure

Configure your function handlers with events as described in the Serverless SNS Documentation

Here's an example serverless.yml config which calls a function on an SNS notifcation. Note that the offline-sns plugin will automatically pick up this config, subscribe to the topic and call the handler on an SNS notification.

functions:
  pong:
    handler: dist/services/hello/index.pong
    events:
      - sns: test-topic

Or you can use the exact ARN of the topic:

functions:
  pong:
    handler: dist/services/hello/index.pong
    events:
      - sns:
        arn: "arn:aws:sns:us-east-1:123456789012:test-topic"

Here's a demo of some code that will trigger this handler:

import AWS = require("aws-sdk");
const sns = new AWS.SNS({
    endpoint: "http://127.0.0.1:4002",
    region: "us-east-1",
});
sns.publish({
    Message: "hello!",
    MessageStructure: "json",
    TopicArn: "arn:aws:sns:us-east-1:123456789012:test-topic",
});

Usage

If you use serverless-offline this plugin will start automatically.

However if you don't use serverless-offline you can start this plugin manually with -

serverless offline-sns start

Contributions and Issues

Happy to accept contributions, feature requests and issues.

Keywords

FAQs

Package last updated on 26 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc