Socket
Socket
Sign inDemoInstall

@0xc/serverless-offline-aws-sqs

Package Overview
Dependencies
4
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @0xc/serverless-offline-aws-sqs

AWS SQS 📤 Plugin for Serverless Framework ⚡️| Webpack support | Local ElasticMQ


Version published
Maintainers
1
Install size
80.1 MB
Created

Readme

Source

builds.sr.ht status License: MIT

serverless-offline-sqs

This Serverless-offline plugin emulates AWS λ and SQS queue on your local machine by using ElasticMQ. To do so, it listens SQS queue and invokes your handlers.

Installation

First, add @0xc/serverless-offline-aws-sqs to your project:

yarn add @0xc/serverless-offline-aws-sqs

Then inside your project's serverless.yml file, add following entry to the plugins section before serverless-offline (and after serverless-webpack if presents): @0xc/serverless-offline-aws-sqs.

plugins:
  - serverless-webpack
  - "@0xc/serverless-offline-aws-sqs"
  - serverless-offline

Configure

Functions

Ths configuration of function of the plugin follows the serverless documentation.

functions:
  mySQSHandler:
    handler: handler.default
    events:
      - sqs:
          queueName: MyQueue
          arn:
            Fn::GetAtt:
              - MyQueue
              - Arn
resources:
  Resources:
    MyQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: MyQueue

Inside your functions you could use a wrapper to switch between local and (aws) production environment.

const AWS = require("aws-sdk");

let options = {};

// connect to local ElasticMQ if running offline
if (process.env.IS_OFFLINE) {
  options = {
    apiVersion: "2012-11-05",
    region: "localhost",
    endpoint: "http://0.0.0.0:9324",
    sslEnabled: false
  };
}

const client = new AWS.SQS(options);

export default client;

Local SQS (ElasticMQ)

The configuration of aws.SQS's client of the plugin is done by defining a custom: serverless-offline-sqs object in your serverless.yml with your specific configuration.

You could use ElasticMQ with the following configuration:

custom:
  "@0xc/serverless-offline-aws-sqs":
    apiVersion: "2012-11-05"
    endpoint: http://0.0.0.0:9324
    region: eu-west-1
    accessKeyId: root
    secretAccessKey: root
    skipCacheInvalidation: false

Before you start your serverless functions you ElasticMQ needs to run.

docker run -it -p 9324:9324 s12v/elasticmq:latest

Queues will be automatically created.

Roadmap

  • install ElasticMQ automatically or start docker automatically

PLEASE HELP ME TO GET THIS DONE! EVERY PR IS WELCOME.

Credits

This is a custom fork from @meuschke/serverless-offline-aws-sqs Project

Keywords

FAQs

Last updated on 12 Jun 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc