awssolutionsconstructsawslambdasqslambda

package module
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

aws-lambda-sqs-lambda module


All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


Reference Documentation: https://docs.aws.amazon.com/solutions/latest/constructs/
Language Package
Python Logo Python aws_solutions_constructs.aws_lambda_sqs_lambda
Typescript Logo Typescript @aws-solutions-constructs/aws-lambda-sqs-lambda
Java Logo Java software.amazon.awsconstructs.services.lambdasqslambda

This AWS Solutions Construct implements (1) an AWS Lambda function that is configured to send messages to a queue; (2) an Amazon SQS queue; and (3) an AWS Lambda function configured to consume messages from the queue.

Here is a minimal deployable pattern definition in Typescript:

import { LambdaToSqsToLambda, LambdaToSqsToLambdaProps } from "@aws-solutions-constructs/aws-lambda-sqs-lambda";

new LambdaToSqsToLambda(this, 'LambdaToSqsToLambdaPattern', {
  producerLambdaFunctionProps: {
      runtime: lambda.Runtime.NODEJS_14_X,
      handler: 'index.handler',
      code: lambda.Code.fromAsset(`${__dirname}/lambda/producer-function`)
  },
  consumerLambdaFunctionProps: {
    runtime: lambda.Runtime.NODEJS_14_X,
    handler: 'index.handler',
    code: lambda.Code.fromAsset(`${__dirname}/lambda/consumer-function`)
  }
});

Initializer

new LambdaToSqsToLambda(scope: Construct, id: string, props: LambdaToSqsToLambdaProps);

Parameters

Pattern Construct Props

Name Type Description
existingProducerLambdaObj? lambda.Function An optional, existing Lambda function to be used instead of the default function for sending messages to the queue. Providing both this and producerLambdaFunctionProps will cause an error.
producerLambdaFunctionProps? lambda.FunctionProps Optional user-provided properties to override the default properties for the producer Lambda function.
existingQueueObj? sqs.Queue An optional, existing SQS queue to be used instead of the default queue. Providing both this and queueProps will cause an error.
queueProps? sqs.QueueProps Optional user-provided properties to override the default properties for the SQS queue. Providing both this and existingQueueObj will cause an error.
deployDeadLetterQueue? boolean Whether to create a secondary queue to be used as a dead letter queue. Defaults to true.
deadLetterQueueProps? sqs.QueueProps Optional user-provided props to override the default props for the dead letter queue. Only used if the deployDeadLetterQueue property is set to true.
maxReceiveCount? number The number of times a message can be unsuccessfully dequeued before being moved to the dead letter queue. Defaults to 15.
existingConsumerLambdaObj? lambda.Function An optional, existing Lambda function to be used instead of the default function for receiving/consuming messages from the queue. Providing both this and consumerLambdaFunctionProps will cause an error.
consumerLambdaFunctionProps? lambda.FunctionProps Optional user-provided properties to override the default properties for the consumer Lambda function.
queueEnvironmentVariableName? string Optional Name for the SQS queue URL environment variable set for the producer Lambda function.
sqsEventSourceProps? SqsEventSourceProps Optional user provided properties for the queue event source.
existingVpc? ec2.IVpc An optional, existing VPC into which this pattern should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources and an Interface Endpoint will be created in the VPC for Amazon SQS. If an existing VPC is provided, the deployVpc property cannot be true. This uses ec2.IVpc to allow clients to supply VPCs that exist outside the stack using the ec2.Vpc.fromLookup() method.
vpcProps? ec2.VpcProps Optional user-provided properties to override the default properties for the new VPC. enableDnsHostnames, enableDnsSupport, natGateways and subnetConfiguration are set by the pattern, so any values for those properties supplied here will be overrriden. If deployVpc is not true then this property will be ignored.
deployVpc? boolean Whether to create a new VPC based on vpcProps into which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:
  • One isolated subnet in each Availability Zone used by the CDK program
  • enableDnsHostnames and enableDnsSupport will both be set to true
If this property is true then existingVpc cannot be specified. Defaults to false.

Pattern Properties

Name Type Description
producerLambdaFunction lambda.Function Returns an instance of the producer Lambda function created by the pattern.
sqsQueue sqs.Queue Returns an instance of the SQS queue created by the pattern.
deadLetterQueue? sqs.Queue | undefined Returns an instance of the dead letter queue created by the pattern, if one is deployed.
consumerLambdaFunction lambda.Function Returns an instance of the consumer Lambda function created by the pattern.
vpc? ec2.IVpc Returns an interface on the VPC used by the pattern (if any). This may be a VPC created by the pattern or the VPC supplied to the pattern constructor.

Default Settings

Out-of-the-box implementation of this Construct (without any overridden properties) will adhere to the following defaults:

AWS Lambda Functions
  • Configure limited privilege access IAM role for Lambda functions.
  • Enable reusing connections with Keep-Alive for NodeJs Lambda functions.
  • Enable X-Ray Tracing
  • Set Environment Variables
    • AWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)
Amazon SQS Queue
  • Deploy a dead letter queue for the primary queue.
  • Enable server-side encryption for the primary queue using an AWS Managed KMS Key.
  • Enforce encryption of data in transit

Architecture

Architecture Diagram


© Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Documentation

Overview

CDK construct that provisions (1) an AWS Lambda function that is configured to send messages to a queue; (2) an Amazon SQS queue; and (3) an AWS Lambda function configured to consume messages from the queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LambdaToSqsToLambda_IsConstruct

func LambdaToSqsToLambda_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead

func NewLambdaToSqsToLambda_Override

func NewLambdaToSqsToLambda_Override(l LambdaToSqsToLambda, scope constructs.Construct, id *string, props *LambdaToSqsToLambdaProps)

Types

type LambdaToSqsToLambda

type LambdaToSqsToLambda interface {
	constructs.Construct
	ConsumerLambdaFunction() awslambda.Function
	DeadLetterQueue() *awssqs.DeadLetterQueue
	Node() constructs.Node
	ProducerLambdaFunction() awslambda.Function
	SqsQueue() awssqs.Queue
	Vpc() awsec2.IVpc
	ToString() *string
}

func NewLambdaToSqsToLambda

func NewLambdaToSqsToLambda(scope constructs.Construct, id *string, props *LambdaToSqsToLambdaProps) LambdaToSqsToLambda

type LambdaToSqsToLambdaProps

type LambdaToSqsToLambdaProps struct {
	// Optional user-provided properties to override the default properties for the consumer Lambda function.
	ConsumerLambdaFunctionProps *awslambda.FunctionProps `json:"consumerLambdaFunctionProps"`
	// Optional user-provided props to override the default props for the dead letter queue.
	//
	// Only used if the
	// `deployDeadLetterQueue` property is set to true.
	DeadLetterQueueProps *awssqs.QueueProps `json:"deadLetterQueueProps"`
	// Whether to create a secondary queue to be used as a dead letter queue.
	//
	// Defaults to `true`.
	DeployDeadLetterQueue *bool `json:"deployDeadLetterQueue"`
	// Whether to deploy a new VPC.
	DeployVpc *bool `json:"deployVpc"`
	// An optional, existing Lambda function to be used instead of the default function for receiving/consuming messages from the queue.
	//
	// Providing both this and `consumerLambdaFunctionProps` will cause an error.
	ExistingConsumerLambdaObj awslambda.Function `json:"existingConsumerLambdaObj"`
	// An optional, existing Lambda function to be used instead of the default function for sending messages to the queue.
	//
	// Providing both this and `producerLambdaFunctionProps` property will cause an error.
	ExistingProducerLambdaObj awslambda.Function `json:"existingProducerLambdaObj"`
	// An optional, existing SQS queue to be used instead of the default queue.
	//
	// Providing both this and `queueProps`
	// will cause an error.
	ExistingQueueObj awssqs.Queue `json:"existingQueueObj"`
	// An existing VPC for the construct to use (construct will NOT create a new VPC in this case).
	ExistingVpc awsec2.IVpc `json:"existingVpc"`
	// The number of times a message can be unsuccessfully dequeued before being moved to the dead letter queue.
	//
	// Defaults to `15`.
	MaxReceiveCount *float64 `json:"maxReceiveCount"`
	// Optional user-provided properties to override the default properties for the producer Lambda function.
	ProducerLambdaFunctionProps *awslambda.FunctionProps `json:"producerLambdaFunctionProps"`
	// Optional Name for the SQS queue URL environment variable set for the producer Lambda function.
	QueueEnvironmentVariableName *string `json:"queueEnvironmentVariableName"`
	// Optional user-provided properties to override the default properties for the SQS queue.
	QueueProps *awssqs.QueueProps `json:"queueProps"`
	// Optional user provided properties for the queue event source.
	SqsEventSourceProps *awslambdaeventsources.SqsEventSourceProps `json:"sqsEventSourceProps"`
	// Properties to override default properties if deployVpc is true.
	VpcProps *awsec2.VpcProps `json:"vpcProps"`
}

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL