@@ -13,6 +13,7 @@ type Config = {
1313 funcName : string ;
1414 prefix : string ;
1515 batchSize : number ;
16+ maximumBatchingWindowInSeconds : number ;
1617 maxRetryCount : number ;
1718 kmsMasterKeyId : string ;
1819 kmsDataKeyReusePeriodSeconds : number ;
@@ -61,16 +62,19 @@ const pascalCase = camelCase =>
6162 * handler: handler.handler
6263 * events:
6364 * - snsSqs:
64- * name: Event
65- * topicArn: !Ref TopicArn
66- * maxRetryCount: 2 # optional - default is 5
67- * batchSize: 1 # optional - default is 10
68- * kmsMasterKeyId: alias/aws/sqs # optional - default is none (no encryption)
69- * kmsDataKeyReusePeriodSeconds: 600 # optional - AWS default is 300 seconds
70- * filterPolicy:KmsMasterKeyId
71- * pet:
72- * - dog
73- * - cat
65+ * name: ResourcePrefix
66+ * topicArn: ${self:custom.topicArn}
67+ * batchSize: 2
68+ * maximumBatchingWindowInSeconds: 30
69+ * maxRetryCount: 2
70+ * kmsMasterKeyId: alias/aws/sqs
71+ * kmsDataKeyReusePeriodSeconds: 600
72+ * visibilityTimeout: 120
73+ * rawMessageDelivery: true
74+ * filterPolicy:
75+ * pet:
76+ * - dog
77+ * - cat
7478 */
7579export default class ServerlessSnsSqsLambda {
7680 serverless : any ;
@@ -185,6 +189,7 @@ Usage
185189 prefix: some-prefix # optional - default is \`\${this.serviceName}-\${stage}-\${funcNamePascalCase}\`
186190 maxRetryCount: 2 # optional - default is 5
187191 batchSize: 1 # optional - default is 10
192+ batchWindow: 10 # optional - default is 0 (no batch window)
188193 kmsMasterKeyId: alias/aws/sqs # optional - default is none (no encryption)
189194 kmsDataKeyReusePeriodSeconds: 600 # optional - AWS default is 300 seconds
190195 deadLetterMessageRetentionPeriodSeconds: 1209600 # optional - AWS default is 345600 secs (4 days)
@@ -230,14 +235,15 @@ Usage
230235 */
231236 addEventSourceMapping (
232237 template ,
233- { funcName, name, batchSize, enabled } : Config
238+ { funcName, name, batchSize, maximumBatchingWindowInSeconds , enabled } : Config
234239 ) {
235240 const enabledWithDefault = enabled !== undefined ? enabled : true ;
236241 template . Resources [ `${ funcName } EventSourceMappingSQS${ name } Queue` ] = {
237242 Type : "AWS::Lambda::EventSourceMapping" ,
238243 DependsOn : "IamRoleLambdaExecution" ,
239244 Properties : {
240245 BatchSize : batchSize ,
246+ MaximumBatchingWindowInSeconds : maximumBatchingWindowInSeconds !== undefined ? maximumBatchingWindowInSeconds : 0 ,
241247 EventSourceArn : { "Fn::GetAtt" : [ `${ name } Queue` , "Arn" ] } ,
242248 FunctionName : { "Fn::GetAtt" : [ `${ funcName } LambdaFunction` , "Arn" ] } ,
243249 Enabled : enabledWithDefault ? "True" : "False"
0 commit comments