Skip to content

Commit 27075c5

Browse files
committed
sdk-v3: Remove lambda in v2 as it is not used
motdotlaGH-641
1 parent b3ba814 commit 27075c5

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/main.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -970,21 +970,18 @@ they may not work as expected in the Lambda environment.
970970
console.log(`=> Uploading zip file to AWS Lambda ${region} with parameters:`)
971971
}
972972
console.log(params)
973-
// Migrating to v3.
974-
const lambda = new aws.sdk.Lambda({
975-
region,
976-
apiVersion: '2015-03-31'
977-
})
978973
const lambdaClient = new LambdaClient({ region })
974+
// Migrating to v3.
975+
// todo: `aws.sdk` is v2, so replace it with v3.
979976
const scheduleEvents = new ScheduleEvents(aws.sdk, region)
980977
const s3Events = new S3Events(aws.sdk, region)
981978
const cloudWatchLogs = new CloudWatchLogs(aws.sdk, region)
982979

983980
const existsFunction = await (async () => {
984981
try {
985-
await lambda.getFunction({
982+
await lambdaClient.send(new GetFunctionCommand({
986983
FunctionName: params.FunctionName
987-
}).promise()
984+
}))
988985
return true
989986
} catch (err) {
990987
if (!this._isFunctionDoesNotExist(err)) {
@@ -995,10 +992,10 @@ they may not work as expected in the Lambda environment.
995992
})()
996993

997994
if (existsFunction) {
998-
const existingEventSourceList = await this._listEventSourceMappings(lambda, {
995+
const existingEventSourceList = await this._listEventSourceMappings(lambdaClient, {
999996
FunctionName: params.FunctionName
1000997
})
1001-
const results = await this._uploadExisting(lambda, params)
998+
const results = await this._uploadExisting(lambdaClient, params)
1002999
console.log('=> Done uploading. Results follow: ')
10031000
console.log(results)
10041001

@@ -1015,12 +1012,12 @@ they may not work as expected in the Lambda environment.
10151012
eventSourceList.S3Events
10161013
),
10171014
this._updateTags(
1018-
lambda,
1015+
lambdaClient,
10191016
results.FunctionArn,
10201017
params.Tags)
10211018
]),
10221019
this._updateEventSources(
1023-
lambda,
1020+
lambdaClient,
10241021
params.FunctionName,
10251022
existingEventSourceList,
10261023
eventSourceList.EventSourceMappings
@@ -1032,13 +1029,13 @@ they may not work as expected in the Lambda environment.
10321029
)
10331030
])
10341031
} else {
1035-
const results = await this._uploadNew(lambda, params)
1032+
const results = await this._uploadNew(lambdaClient, params)
10361033
console.log('=> Done uploading. Results follow: ')
10371034
console.log(results)
10381035

10391036
return Promise.all([
10401037
this._updateEventSources(
1041-
lambda,
1038+
lambdaClient,
10421039
params.FunctionName,
10431040
[],
10441041
eventSourceList.EventSourceMappings

0 commit comments

Comments
 (0)