File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -617,6 +617,13 @@ they may not work as expected in the Lambda environment.
617617 } )
618618 }
619619
620+ _getStartingPosition ( eventSource ) {
621+ if ( eventSource . EventSourceArn . indexOf ( 'arn:aws:sqs:' ) === 0 ) {
622+ return null
623+ }
624+ return eventSource . StartingPosition ? eventSource . StartingPosition : 'LATEST'
625+ }
626+
620627 _updateEventSources ( lambda , functionName , existingEventSourceList , eventSourceList ) {
621628 if ( eventSourceList == null ) {
622629 return Promise . resolve ( [ ] )
@@ -647,7 +654,7 @@ they may not work as expected in the Lambda environment.
647654 'EventSourceArn' : eventSourceList [ i ] [ 'EventSourceArn' ] ,
648655 'Enabled' : eventSourceList [ i ] [ 'Enabled' ] ? eventSourceList [ i ] [ 'Enabled' ] : false ,
649656 'BatchSize' : eventSourceList [ i ] [ 'BatchSize' ] ? eventSourceList [ i ] [ 'BatchSize' ] : 100 ,
650- 'StartingPosition' : eventSourceList [ i ] [ 'StartingPosition' ] ? eventSourceList [ i ] [ 'StartingPosition' ] : 'LATEST'
657+ 'StartingPosition' : this . _getStartingPosition ( eventSourceList [ i ] )
651658 } )
652659 }
653660 }
Original file line number Diff line number Diff line change @@ -989,6 +989,33 @@ describe('lib/main', function () {
989989 } )
990990 } )
991991
992+ describe ( '_getStartingPosition' , ( ) => {
993+ it ( 'null in SQS' , ( ) => {
994+ assert . isNull ( lambda . _getStartingPosition ( {
995+ EventSourceArn : 'arn:aws:sqs:us-east-1:sqs-queuename1'
996+ } ) )
997+ } )
998+
999+ it ( 'When there is no setting' , ( ) => {
1000+ assert . equal (
1001+ lambda . _getStartingPosition ( {
1002+ EventSourceArn : 'arn:aws:kinesis:test'
1003+ } ) ,
1004+ 'LATEST'
1005+ )
1006+ } )
1007+
1008+ it ( 'With StartingPosition' , ( ) => {
1009+ assert . equal (
1010+ lambda . _getStartingPosition ( {
1011+ EventSourceArn : 'arn:aws:kinesis:test' ,
1012+ StartingPosition : 'test position'
1013+ } ) ,
1014+ 'test position'
1015+ )
1016+ } )
1017+ } )
1018+
9921019 describe ( '_updateEventSources' , ( ) => {
9931020 const eventSourcesJsonValue = {
9941021 EventSourceMappings : [ {
You can’t perform that action at this time.
0 commit comments