@@ -19,6 +19,10 @@ const CloudWatchLogs = require(path.join(__dirname, 'cloudwatch_logs'))
1919const AWSXRay = require ( 'aws-xray-sdk-core' )
2020const { createNamespace } = require ( 'continuation-local-storage' )
2121
22+ // Migrating to v3.
23+ const { LambdaClient, CreateFunctionCommand } = require ( '@aws-sdk/client-lambda' )
24+ const lambdaClient = new LambdaClient ( )
25+
2226const maxBufferSize = 50 * 1024 * 1024
2327
2428class Lambda {
@@ -236,8 +240,8 @@ Emulate only the body of the API Gateway event.
236240 Role : program . role ,
237241 Runtime : program . runtime ,
238242 Description : program . description ,
239- MemorySize : program . memorySize ,
240- Timeout : program . timeout ,
243+ MemorySize : Number ( program . memorySize ) ,
244+ Timeout : Number ( program . timeout ) ,
241245 Architectures : program . architecture ? [ program . architecture ] : [ 'x86_64' ] ,
242246 Publish : ( ( ) => {
243247 if ( typeof program . publish === 'boolean' ) {
@@ -688,6 +692,13 @@ Emulate only the body of the API Gateway event.
688692 }
689693
690694 _uploadNew ( lambda , params ) {
695+ if ( process . env . USE_AWS_SDK_V3 ) {
696+ // todo retry
697+ console . log ( 'DEBUG: Use AWS SDK V3: CreateFunctionCommand()' )
698+ const command = new CreateFunctionCommand ( params )
699+ return lambdaClient . send ( command )
700+ }
701+
691702 return new Promise ( ( resolve , reject ) => {
692703 const request = lambda . createFunction ( params , ( err , data ) => {
693704 if ( err ) return reject ( err )
0 commit comments