@@ -970,21 +970,18 @@ they may not work as expected in the Lambda environment.
970
970
console . log ( `=> Uploading zip file to AWS Lambda ${ region } with parameters:` )
971
971
}
972
972
console . log ( params )
973
- // Migrating to v3.
974
- const lambda = new aws . sdk . Lambda ( {
975
- region,
976
- apiVersion : '2015-03-31'
977
- } )
978
973
const lambdaClient = new LambdaClient ( { region } )
974
+ // Migrating to v3.
975
+ // todo: `aws.sdk` is v2, so replace it with v3.
979
976
const scheduleEvents = new ScheduleEvents ( aws . sdk , region )
980
977
const s3Events = new S3Events ( aws . sdk , region )
981
978
const cloudWatchLogs = new CloudWatchLogs ( aws . sdk , region )
982
979
983
980
const existsFunction = await ( async ( ) => {
984
981
try {
985
- await lambda . getFunction ( {
982
+ await lambdaClient . send ( new GetFunctionCommand ( {
986
983
FunctionName : params . FunctionName
987
- } ) . promise ( )
984
+ } ) )
988
985
return true
989
986
} catch ( err ) {
990
987
if ( ! this . _isFunctionDoesNotExist ( err ) ) {
@@ -995,10 +992,10 @@ they may not work as expected in the Lambda environment.
995
992
} ) ( )
996
993
997
994
if ( existsFunction ) {
998
- const existingEventSourceList = await this . _listEventSourceMappings ( lambda , {
995
+ const existingEventSourceList = await this . _listEventSourceMappings ( lambdaClient , {
999
996
FunctionName : params . FunctionName
1000
997
} )
1001
- const results = await this . _uploadExisting ( lambda , params )
998
+ const results = await this . _uploadExisting ( lambdaClient , params )
1002
999
console . log ( '=> Done uploading. Results follow: ' )
1003
1000
console . log ( results )
1004
1001
@@ -1015,12 +1012,12 @@ they may not work as expected in the Lambda environment.
1015
1012
eventSourceList . S3Events
1016
1013
) ,
1017
1014
this . _updateTags (
1018
- lambda ,
1015
+ lambdaClient ,
1019
1016
results . FunctionArn ,
1020
1017
params . Tags )
1021
1018
] ) ,
1022
1019
this . _updateEventSources (
1023
- lambda ,
1020
+ lambdaClient ,
1024
1021
params . FunctionName ,
1025
1022
existingEventSourceList ,
1026
1023
eventSourceList . EventSourceMappings
@@ -1032,13 +1029,13 @@ they may not work as expected in the Lambda environment.
1032
1029
)
1033
1030
] )
1034
1031
} else {
1035
- const results = await this . _uploadNew ( lambda , params )
1032
+ const results = await this . _uploadNew ( lambdaClient , params )
1036
1033
console . log ( '=> Done uploading. Results follow: ' )
1037
1034
console . log ( results )
1038
1035
1039
1036
return Promise . all ( [
1040
1037
this . _updateEventSources (
1041
- lambda ,
1038
+ lambdaClient ,
1042
1039
params . FunctionName ,
1043
1040
[ ] ,
1044
1041
eventSourceList . EventSourceMappings
0 commit comments