Package: aws-solutions-constructs.aws-lambda-sqs
aws-lambda-sqs module---Reference Documentation:https://docs.aws.amazon.com/solutions/latest/constructs/LanguagePackagePythonaws_solutions_constructs.aws_lambda_sqsTypescript@aws-solutions-constructs/aws-lambda-sqsJavasoftware.amazon.awsconstructs.services.lambdasqsOverviewThis AWS Solutions Construct implements an AWS Lambda function connected to an Amazon SQS queue.Here is a minimal deployable pattern definition:Typescriptimport{Construct}from'constructs';import{Stack,StackProps}from'aws-cdk-lib';import{LambdaToSqs,LambdaToSqsProps}from"@aws-solutions-constructs/aws-lambda-sqs";import*aslambdafrom'aws-cdk-lib/aws-lambda';newLambdaToSqs(this,'LambdaToSqsPattern',{lambdaFunctionProps:{runtime:lambda.Runtime.NODEJS_16_X,handler:'index.handler',code:lambda.Code.fromAsset(`lambda`)}});Pythonfromaws_solutions_constructs.aws_lambda_sqsimportLambdaToSqsfromaws_cdkimport(aws_lambdaas_lambda,Stack)fromconstructsimportConstructLambdaToSqs(self,'test-lambda-sqs-stack',lambda_function_props=_lambda.FunctionProps(code=_lambda.Code.from_asset('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.lambdasqs.*;newLambdaToSqs(this,"test-lambda-sqs-stack",newLambdaToSqsProps.Builder().lambdaFunctionProps(newFunctionProps.Builder().runtime(Runtime.NODEJS_16_X).code(Code.fromAsset("lambda")).handler("index.handler").build()).build());Pattern Construct PropsNameTypeDescriptionexistingLambdaObj?lambda.FunctionAn optional, existing Lambda function to be used instead of the default function. Providing both this andlambdaFunctionPropswill cause an error.lambdaFunctionProps?lambda.FunctionPropsOptional user-provided properties to override the default properties for the 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.enableQueuePurging?booleanWhether to grant additional permissions to the Lambda function enabling it to purge the SQS queue. Defaults tofalse.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 to true.maxReceiveCount?numberThe number of times a message can be unsuccessfully dequeued before being moved to the dead letter queue. Defaults to15.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.queueEnvironmentVariableName?stringOptional Name for the Lambda function environment variable set to the URL of the queue. Default: SQS_QUEUE_URLenableEncryptionWithCustomerManagedKey?booleanIf no key is provided, this flag determines whether the queue is encrypted with a new CMK or an AWS managed key. This flag is ignored if any of the following are defined: queueProps.encryptionMasterKey, encryptionKey or encryptionKeyProps.encryptionKey?kms.KeyAn optional, imported encryption key to encrypt the SQS Queue with.encryptionKeyProps?kms.KeyPropsOptional user provided properties to override the default properties for the KMS encryption key used to encrypt the SQS queue with.Pattern PropertiesNameTypeDescriptionlambdaFunctionlambda.FunctionReturns an instance of the Lambda function created by the pattern.sqsQueuesqs.QueueReturns an instance of the SQS queue created by the pattern.deadLetterQueue?sqs.QueueReturns an instance of the dead letter queue created by the pattern, if one is deployed.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 the Construct without any override will set the following defaults:AWS Lambda FunctionConfigure limited privilege access IAM role for Lambda function.Enable reusing connections with Keep-Alive for NodeJs Lambda function.Allow the function to send messages only to the queue (purging can be enabled using theenableQueuePurgeproperty).Enable X-Ray TracingSet Environment VariablesSQS_QUEUE_URLAWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)Amazon SQS QueueDeploy SQS dead-letter queue for the source SQS Queue.Enable server-side encryption for source SQS Queue using AWS Managed KMS Key.Enforce encryption of data in transitArchitecture© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.