@@ -28,7 +28,6 @@ const { createNamespace } = require('continuation-local-storage')
28
28
* https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html
29
29
*/
30
30
const { LambdaClient, CreateFunctionCommand } = require ( '@aws-sdk/client-lambda' )
31
- const lambdaClient = new LambdaClient ( )
32
31
33
32
const maxBufferSize = 50 * 1024 * 1024
34
33
@@ -699,22 +698,7 @@ Emulate only the body of the API Gateway event.
699
698
}
700
699
701
700
_uploadNew ( lambda , params ) {
702
- if ( process . env . USE_AWS_SDK_V3 ) {
703
- console . log ( 'DEBUG: Use AWS SDK V3: CreateFunctionCommand()' )
704
- const command = new CreateFunctionCommand ( params )
705
- return lambdaClient . send ( command )
706
- }
707
-
708
- return new Promise ( ( resolve , reject ) => {
709
- const request = lambda . createFunction ( params , ( err , data ) => {
710
- if ( err ) return reject ( err )
711
- resolve ( data )
712
- } )
713
- request . on ( 'retry' , ( response ) => {
714
- console . log ( response . error . message )
715
- console . log ( '=> Retrying' )
716
- } )
717
- } )
701
+ return lambda . send ( new CreateFunctionCommand ( params ) )
718
702
}
719
703
720
704
_readArchive ( program ) {
@@ -991,6 +975,7 @@ they may not work as expected in the Lambda environment.
991
975
}
992
976
993
977
_deployToRegion ( program , params , region , buffer ) {
978
+ // sdk v3 todo: Migration of aws.updateConfig.
994
979
aws . updateConfig ( program , region )
995
980
996
981
console . log ( '=> Reading event source file to memory' )
@@ -1012,10 +997,13 @@ they may not work as expected in the Lambda environment.
1012
997
}
1013
998
console . log ( params )
1014
999
1000
+ // Migrating to v3.
1015
1001
const lambda = new aws . sdk . Lambda ( {
1016
1002
region,
1017
1003
apiVersion : '2015-03-31'
1018
1004
} )
1005
+ const lambdaClient = new LambdaClient ( { region } )
1006
+
1019
1007
const scheduleEvents = new ScheduleEvents ( aws . sdk , region )
1020
1008
const s3Events = new S3Events ( aws . sdk , region )
1021
1009
const cloudWatchLogs = new CloudWatchLogs ( aws . sdk , region )
@@ -1069,7 +1057,7 @@ they may not work as expected in the Lambda environment.
1069
1057
throw err
1070
1058
}
1071
1059
// Function does not exist
1072
- return this . _uploadNew ( lambda , params ) . then ( ( results ) => {
1060
+ return this . _uploadNew ( lambdaClient , params ) . then ( ( results ) => {
1073
1061
console . log ( '=> Done uploading. Results follow: ' )
1074
1062
console . log ( results )
1075
1063
0 commit comments