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

@matthewbonig/sqs-redrive

v2.0.1

Published

A redrive construct to use with an SQS queue and it's dead letter queue

Downloads

11

Readme

SQS Redrive

This construct creates a Lambda function that you can use to move SQS messages from one queue to another. This is often used for moving Dead Letter Queue messages back to the original queue for reprocessing.

DEPRECATED

AWS recently announced an update to the SQS API that builds a redrive directly into the service:

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_StartMessageMoveTask.html

With this API update, this construct is no longer required and you should stop using it. I will no longer be making any updates to it.

This is a pre-release!

This is a quick first-draft. All the options that will likely need to be added to accomodate a large number of use-cases are still needed. If you'd like to make requests or help update this construct, please open an Issue or a PR.

What Gets Created

A Lambda function and related policy which moves SQS queue messages from one queue to another.

Example

This creates two external queues and then creates the Lambda to move from the deadLetterQueue to the mainQueue

import * as cdk from '@aws-cdk/core';
import {SqsRedrive} from '../lib/sqs-redrive';
import {Queue} from "@aws-cdk/aws-sqs";

const app = new cdk.App();
const stack = new cdk.Stack(app, 'test-stack');

let mainQueue = new Queue(stack, 'main-queue');
let deadLetterQueue = new Queue(stack, 'dlq-queue');
new SqsRedrive(stack, 'SqsRedriveConstructStack', {
    mainQueue: mainQueue,
    deadLetterQueue: deadLetterQueue
});

Note: this is the integration test (cdk synth).

Input Properties

What are the inputs to your constructs?

|property|description|example |---|---|--- |mainQueue|The destination queue for the messages.|new Queue(stack, 'main-queue') |deadLetterQueue|The source queue of the messages.|new Queue(stack, 'dead-letter-queue')

Overriding Lambda Props

You can supply your own properties to the Lambda Function constructor. They're mashed together with some defaults. Pay attention to the order:

this.redriveFunction = new NodejsFunction(this, `${id}-queue-redrive`, {
  functionName: id,
  entry: join(__dirname, 'sqs-redrive.queue-redrive.lambda.ts'),
  ...props.lambdaProps,
  environment: {
    QUEUE_URL: props.mainQueue.queueUrl,
    DLQ_URL: props.deadLetterQueue!.queueUrl,
    ...props?.lambdaProps?.environment,
  },
});

functionName and entry can be overridden. Environment variables will always be splatted with the two queue URLs so you never have to worry about specifying those (you can, of course, override them, but if you're going that far then why are you using this construct?).

Output Properties

After constructed, you can gain access to the Lambda Function:

const redrive = new SqsRedrive(stack, 'SqsRedriveConstructStack', {
                    mainQueue: mainQueue,
                    deadLetterQueue: deadLetterQueue
                });

// redrive.redriveFunction is an IFunction 

Design Notes

This is early design and serves one very specific use-case. If you have suggestions on how to make this better, please open an Issue in Github.

Contributing

Please open Pull Requests and Issues on the Github Repo.

License

MIT