npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sqs-to-lambda

v1.1.0

Published

Trigger Lambda invocations from an SQS queue

Downloads

19

Readme

sqs-to-lambda

Trigger Lambda invocations from an SQS queue

This application listens to an SQS queue and creates a Lambda invocation whenever a message is received, bridging the gap between SQS and Lambda.

Having to run this application continually isn't ideal when your aim is to execute a function only when you need to – ~~it's a stop gap measure until SQS/SNS support (hopefully) arrives in Lambda~~.

Update: Lambda now supports SNS notifications as an event source, which makes this hack entirely unneccessary for SNS notifcations. You might still find it useful if you like the idea of using a Lambda function to process jobs on an SQS queue.

Installation

npm install -g sqs-to-lambda

Usage

The application needs to run as an IAM user that has permission to consume from your queue and invoke any Lambda functions. If you're running it in EC2 then it will authenticate using an instance profile, otherwise you need to export your credentials:

export AWS_SECRET_ACCESS_KEY=...
export AWS_ACCESS_KEY_ID=...

Start the application:

sqs-to-lambda --queue-url <queue-url> --function-name <function-name> --region <aws-region-id>

Alternatively, you can also use environment variables to configure the application:

AWS_QUEUE_URL=<queue-url> AWS_FUNCTION_NAME=<function-name> AWS_REGION=<aws-region-id> sqs-to-lambda

Note that if both environment variables are set and arguments are passed as flags, the arguments take precedence.

SQS message format

The SQS message body should be in JSON format. The content of the message is passed to your Lambda function as its first argument. For example:

SQS message body

{
  "name": "Robin Murphy",
  "email": "[email protected]"
}

Lambda function

exports.handler = function (data, context) {
  console.log("Name:", data.name);
  console.log("Email:", data.email);
  context.done();
}