Package: aws-solutions-constructs.aws-lambda-sqs-lambda
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 theSemantic Versioningmodel.
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/LanguagePackagePythonaws_solutions_constructs.aws_lambda_sqs_lambdaTypescript@aws-solutions-constructs/aws-lambda-sqs-lambdaJavasoftware.amazon.awsconstructs.services.lambdasqslambdaOverviewThis 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:Typescriptimport{Construct}from'constructs';import{Stack,StackProps}from'aws-cdk-lib';import{LambdaToSqsToLambda,LambdaToSqsToLambdaProps}from"@aws-solutions-constructs/aws-lambda-sqs-lambda";import*aslambdafrom'aws-cdk-lib/aws-lambda';newLambdaToSqsToLambda(this,'LambdaToSqsToLambdaPattern',{producerLambdaFunctionProps:{runtime:lambda.Runtime.NODEJS_16_X,handler:'index.handler',code:lambda.Code.fromAsset(`producer-lambda`)},consumerLambdaFunctionProps:{runtime:lambda.Runtime.NODEJS_16_X,handler:'index.handler',code:lambda.Code.fromAsset(`consumer-lambda`)}});Pythonfromaws_solutions_constructs.aws_lambda_sqs_lambdaimportLambdaToSqsToLambdafromaws_cdkimport(aws_lambdaas_lambda,Stack)fromconstructsimportConstructLambdaToSqsToLambda(self,'LambdaToSqsToLambdaPattern',producer_lambda_function_props=_lambda.FunctionProps(code=_lambda.Code.from_asset('producer_lambda'),runtime=_lambda.Runtime.PYTHON_3_9,handler='index.handler'),consumer_lambda_function_props=_lambda.FunctionProps(code=_lambda.Code.from_asset('consumer_lambda'),runtime=_lambda.Runtime.PYTHON_3_9,handler='index.handler'))Javaimportsoftware.constructs.Construct;importsoftware.amazon.awscdk.Stack;importsoftware.amazon.awscdk.StackProps;importsoftware.amazon.awscdk.services.lambda.*;importsoftware.amazon.awscdk.services.lambda.Runtime;importsoftware.amazon.awsconstructs.services.lambdasqslambda.*;newLambdaToSqsToLambda(this,"LambdaToSqsToLambdaPattern",newLambdaToSqsToLambdaProps.Builder().producerLambdaFunctionProps(newFunctionProps.Builder().runtime(Runtime.NODEJS_16_X).code(Code.fromAsset("producer-lambda")).handler("index.handler").build()).consumerLambdaFunctionProps(newFunctionProps.Builder().runtime(Runtime.NODEJS_16_X).code(Code.fromAsset("consumer-lambda")).handler("index.handler").build()).build());Pattern Construct PropsNameTypeDescriptionexistingProducerLambdaObj?lambda.FunctionAn optional, existing Lambda function to be used instead of the default function for sending messages to the queue. Providing both this andproducerLambdaFunctionPropswill cause an error.producerLambdaFunctionProps?lambda.FunctionPropsOptional user-provided properties to override the default properties for the producer Lambda function.existingQueueObj?sqs.QueueAn optional, existing SQS queue to be used instead of the default queue. Providing both this andqueuePropswill cause an error.queueProps?sqs.QueuePropsOptional user-provided properties to override the default properties for the SQS queue. Providing both this andexistingQueueObjwill cause an error.deployDeadLetterQueue?booleanWhether to create a secondary queue to be used as a dead letter queue. Defaults totrue.deadLetterQueueProps?sqs.QueuePropsOptional user-provided props to override the default props for the dead letter queue. Only used if thedeployDeadLetterQueueproperty is set totrue.maxReceiveCount?numberThe number of times a message can be unsuccessfully dequeued before being moved to the dead letter queue. Defaults to15.existingConsumerLambdaObj?lambda.FunctionAn optional, existing Lambda function to be used instead of the default function for receiving/consuming messages from the queue. Providing both this andconsumerLambdaFunctionPropswill cause an error.consumerLambdaFunctionProps?lambda.FunctionPropsOptional user-provided properties to override the default properties for the consumer Lambda function.queueEnvironmentVariableName?stringOptional Name for the Lambda function environment variable set to the URL of the queue. Default: SQS_QUEUE_URLsqsEventSourceProps?SqsEventSourcePropsOptional user provided properties for the queue event source.existingVpc?ec2.IVpcAn 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, thedeployVpcproperty cannot betrue. This usesec2.IVpcto allow clients to supply VPCs that exist outside the stack using theec2.Vpc.fromLookup()method.vpcProps?ec2.VpcPropsOptional user-provided properties to override the default properties for the new VPC.enableDnsHostnames,enableDnsSupport,natGatewaysandsubnetConfigurationare set by the pattern, so any values for those properties supplied here will be overridden. IfdeployVpcis nottruethen this property will be ignored.deployVpc?booleanWhether to create a new VPC based onvpcPropsinto 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 programenableDnsHostnamesandenableDnsSupportwill both be set to trueIf this property istruethenexistingVpccannot be specified. Defaults tofalse.Pattern PropertiesNameTypeDescriptionproducerLambdaFunctionlambda.FunctionReturns an instance of the producer Lambda function created by the pattern.sqsQueuesqs.QueueReturns an instance of the SQS queue created by the pattern.deadLetterQueue?sqs.Queue | undefinedReturns an instance of the dead letter queue created by the pattern, if one is deployed.consumerLambdaFunctionlambda.FunctionReturns an instance of the consumer Lambda function created by the pattern.vpc?ec2.IVpcReturns 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 SettingsOut-of-the-box implementation of this Construct (without any overridden properties) will adhere to the following defaults:AWS Lambda FunctionsConfigure limited privilege access IAM role for Lambda functions.Enable reusing connections with Keep-Alive for NodeJs Lambda functions.Enable X-Ray TracingSet Environment VariablesAWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)Amazon SQS QueueDeploy 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 transitArchitecture© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.