@@ -27,7 +27,13 @@ const { createNamespace } = require('continuation-local-storage')
2727 * The default retry count is 3, and only retryable errors will be retried.
2828 * https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html
2929 */
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' )
3137
3238const maxBufferSize = 50 * 1024 * 1024
3339
@@ -671,28 +677,18 @@ Emulate only the body of the API Gateway event.
671677 delete functionConfigParams . Layers
672678 }
673679
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 ) )
680681
681682 // Wait for the `Configuration.LastUpdateStatus` to change from `InProgress` to `Successful`.
683+ const getFunction = new GetFunctionCommand ( { FunctionName : params . FunctionName } )
682684 for ( let i = 0 ; i < 10 ; i ++ ) {
683- const data = await lambda . getFunction ( { FunctionName : params . FunctionName } ) . promise ( )
685+ const data = await lambda . send ( getFunction )
684686 if ( data . Configuration . LastUpdateStatus === 'Successful' ) {
685687 break
686688 }
687689 await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) )
688690 }
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 ) )
696692
697693 return updateConfigResponse
698694 }
0 commit comments