@@ -19,6 +19,10 @@ const CloudWatchLogs = require(path.join(__dirname, 'cloudwatch_logs'))
19
19
const AWSXRay = require ( 'aws-xray-sdk-core' )
20
20
const { createNamespace } = require ( 'continuation-local-storage' )
21
21
22
+ // Migrating to v3.
23
+ const { LambdaClient, CreateFunctionCommand } = require ( '@aws-sdk/client-lambda' )
24
+ const lambdaClient = new LambdaClient ( )
25
+
22
26
const maxBufferSize = 50 * 1024 * 1024
23
27
24
28
class Lambda {
@@ -236,8 +240,8 @@ Emulate only the body of the API Gateway event.
236
240
Role : program . role ,
237
241
Runtime : program . runtime ,
238
242
Description : program . description ,
239
- MemorySize : program . memorySize ,
240
- Timeout : program . timeout ,
243
+ MemorySize : Number ( program . memorySize ) ,
244
+ Timeout : Number ( program . timeout ) ,
241
245
Architectures : program . architecture ? [ program . architecture ] : [ 'x86_64' ] ,
242
246
Publish : ( ( ) => {
243
247
if ( typeof program . publish === 'boolean' ) {
@@ -688,6 +692,13 @@ Emulate only the body of the API Gateway event.
688
692
}
689
693
690
694
_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
+
691
702
return new Promise ( ( resolve , reject ) => {
692
703
const request = lambda . createFunction ( params , ( err , data ) => {
693
704
if ( err ) return reject ( err )
0 commit comments