Socket
Socket
Sign inDemoInstall

@aws-cdk/aws-sqs

Package Overview
Dependencies
2
Maintainers
4
Versions
288
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-sqs


Version published
Weekly downloads
106K
decreased by-11.03%
Maintainers
4
Created
Weekly downloads
 

Package description

What is @aws-cdk/aws-sqs?

@aws-cdk/aws-sqs is an AWS Cloud Development Kit (CDK) library that allows you to define Amazon Simple Queue Service (SQS) queues in your AWS infrastructure as code. It provides a high-level, object-oriented abstraction to create and manage SQS queues, configure their properties, and integrate them with other AWS services.

What are @aws-cdk/aws-sqs's main functionalities?

Create an SQS Queue

This code sample demonstrates how to create a basic SQS queue with a visibility timeout of 300 seconds using the AWS CDK.

const cdk = require('@aws-cdk/core');
const sqs = require('@aws-cdk/aws-sqs');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const queue = new sqs.Queue(this, 'MyQueue', {
      visibilityTimeout: cdk.Duration.seconds(300)
    });
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Configure Dead-Letter Queue

This code sample shows how to configure a dead-letter queue for an SQS queue. Messages that are not successfully processed after 5 attempts will be moved to the dead-letter queue.

const cdk = require('@aws-cdk/core');
const sqs = require('@aws-cdk/aws-sqs');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const deadLetterQueue = new sqs.Queue(this, 'DeadLetterQueue');

    const queue = new sqs.Queue(this, 'MyQueue', {
      deadLetterQueue: {
        queue: deadLetterQueue,
        maxReceiveCount: 5
      }
    });
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Integrate SQS with Lambda

This code sample demonstrates how to integrate an SQS queue with an AWS Lambda function. The Lambda function will be triggered whenever a new message is added to the SQS queue.

const cdk = require('@aws-cdk/core');
const sqs = require('@aws-cdk/aws-sqs');
const lambda = require('@aws-cdk/aws-lambda');
const lambdaEventSources = require('@aws-cdk/aws-lambda-event-sources');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const queue = new sqs.Queue(this, 'MyQueue');

    const myFunction = new lambda.Function(this, 'MyFunction', {
      runtime: lambda.Runtime.NODEJS_14_X,
      handler: 'index.handler',
      code: lambda.Code.fromAsset('lambda')
    });

    myFunction.addEventSource(new lambdaEventSources.SqsEventSource(queue));
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Other packages similar to @aws-cdk/aws-sqs

Changelog

Source

0.8.1 - 2018-08-08

Features

  • aws-cdk: Support --profile in command-line toolkit ([@rix0rrr] in #517)
  • @aws-cdk/cdk: Introduce Default construct id ([@rix0rrr] in #496)
  • @aws-cdk/aws-lambda: Add LambdaRuntime.DotNetCore21 ([@Mortifera] in #507)
  • @aws-cdk/runtime-values (BREAKING): rename 'rtv' to 'runtime-values' ([@rix0rrr] in #494)
  • @aws-cdk/aws-ec2: Combine Connections and DefaultConnections classes ([@rix0rrr] in #453)
  • @aws-cdk/aws-codebuild: allow buildSpec parameter to take a filename ([@rix0rrr] in #470)
  • @aws-cdk/aws-cloudformation-codepipeline: add support for CloudFormation CodePipeline actions ([@mindstorms6] and [@rix0rrr] in #525).
  • docs: Improvements to Getting Started ([@eladb] in #462)
  • docs: Updates to README ([@Doug-AWS] in #456)
  • docs: Upgraded jsii-pacmak to 0.6.4, which includes "language-native" type names and package coordinates ([@RomainMuller] in awslabs/jsii#130)

Bug fixes

  • aws-cdk (toolkit): Fix java cdk init template ([@RomainMuller] in #490)
  • @aws-cdk/cdk (BREAKING): Align FnJoin signature to CloudFormation ([@RomainMuller] in #516)
  • @aws-cdk/aws-cloudfront: Fix origin error ([@mindstorms6] in #514)
  • @aws-cdk/aws-lambda: Invalid cast for inline LambdaRuntime members in Java ([@eladb] in #505)
  • examples: Fixed java examples ([@RomainMuller] in #498)

Readme

Source

AWS SQS Construct Library

Here's how to add a basic queue to your application:

new Queue(this, 'Queue');

Encryption

If you want to encrypt the queue contents, set the encryption property. You can have the messages encrypted with a key that SQS manages for you, or a key that you can manage yourself.

// Use managed key
new Queue(this, 'Queue', {
    encryption: QueueEncryption.Managed,
});

// Use custom key
const myKey = new EncryptionKey(this, 'Key');

new Queue(this, 'Queue', {
    encryption: QueueEncryption.Kms,
    encryptionMasterKey: myKey
});

First-In-First-Out (FIFO) queues

FIFO queues give guarantees on the order in which messages are dequeued, and have additional features in order to help guarantee exactly-once processing. For more information, see the SQS manual. Note that FIFO queues are not available in all AWS regions.

A queue can be made a FIFO queue by either setting fifo: true, giving it a name which ends in ".fifo", or enabling content-based deduplication (which requires FIFO queues).

Keywords

FAQs

Last updated on 09 Aug 2018

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc