@@ -27,7 +27,13 @@ const { createNamespace } = require('continuation-local-storage')
27
27
* The default retry count is 3, and only retryable errors will be retried.
28
28
* https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html
29
29
*/
30
- const { LambdaClient, CreateFunctionCommand } = require ( '@aws-sdk/client-lambda' )
30
+ const {
31
+ LambdaClient,
32
+ CreateFunctionCommand,
33
+ GetFunctionCommand,
34
+ UpdateFunctionCodeCommand,
35
+ UpdateFunctionConfigurationCommand
36
+ } = require ( '@aws-sdk/client-lambda' )
31
37
32
38
const maxBufferSize = 50 * 1024 * 1024
33
39
@@ -671,28 +677,18 @@ Emulate only the body of the API Gateway event.
671
677
delete functionConfigParams . Layers
672
678
}
673
679
674
- const updateConfigRequest = lambda . updateFunctionConfiguration ( functionConfigParams )
675
- updateConfigRequest . on ( 'retry' , ( response ) => {
676
- console . log ( response . error . message )
677
- console . log ( '=> Retrying' )
678
- } )
679
- const updateConfigResponse = await updateConfigRequest . promise ( )
680
+ const updateConfigResponse = await lambda . send ( new UpdateFunctionConfigurationCommand ( functionConfigParams ) )
680
681
681
682
// Wait for the `Configuration.LastUpdateStatus` to change from `InProgress` to `Successful`.
683
+ const getFunction = new GetFunctionCommand ( { FunctionName : params . FunctionName } )
682
684
for ( let i = 0 ; i < 10 ; i ++ ) {
683
- const data = await lambda . getFunction ( { FunctionName : params . FunctionName } ) . promise ( )
685
+ const data = await lambda . send ( getFunction )
684
686
if ( data . Configuration . LastUpdateStatus === 'Successful' ) {
685
687
break
686
688
}
687
689
await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) )
688
690
}
689
-
690
- const updateCodeRequest = lambda . updateFunctionCode ( functionCodeParams )
691
- updateCodeRequest . on ( 'retry' , ( response ) => {
692
- console . log ( response . error . message )
693
- console . log ( '=> Retrying' )
694
- } )
695
- await updateCodeRequest . promise ( )
691
+ lambda . send ( new UpdateFunctionCodeCommand ( functionCodeParams ) )
696
692
697
693
return updateConfigResponse
698
694
}
@@ -1017,7 +1013,7 @@ they may not work as expected in the Lambda environment.
1017
1013
FunctionName : params . FunctionName
1018
1014
} ) . then ( ( existingEventSourceList ) => {
1019
1015
return Promise . all ( [
1020
- this . _uploadExisting ( lambda , params ) . then ( ( results ) => {
1016
+ this . _uploadExisting ( lambdaClient , params ) . then ( ( results ) => {
1021
1017
console . log ( '=> Done uploading. Results follow: ' )
1022
1018
console . log ( results )
1023
1019
return results
0 commit comments