11'use strict' ;
2- const AWS = require ( ' aws-sdk' ) ;
3- AWS . config . region = process . env . AWS_REGION ; // set your Environment Variables...
4- const lambda = new AWS . Lambda ( ) ;
2+ const AWS = require ( "@ aws-sdk/client-lambda" ) ;
3+ const lambda = new AWS . Lambda ( { region : process . env . AWS_REGION } ) ;
4+
55const fs = require ( 'fs' ) ; // so we can read the zip file
66const assert = require ( 'assert' ) ;
77const utils = require ( '../lib/utils' ) ;
@@ -22,20 +22,15 @@ module.exports = function upload (pkg, callback) {
2222 pkg = PKG
2323 }
2424 const FUNCTION_NAME = utils . functionName ( pkg ) ;
25- // try {
26- lambda . getFunction ( { FunctionName : FUNCTION_NAME } , function ( err , data ) {
27- /* istanbul ignore else */
28- if ( err ) { // if the function does not already exist we create it.
29- console . error ( 'upload lambda.getFunction error:' , err ) ;
30- return lambda . createFunction ( createParams ( pkg ) , callback ) ;
31- } else { // otherwise update the *existing* lambda function:
32- return updateFunction ( pkg , callback ) ;
33- }
34- } ) ;
35- // } catch (error) {
36- // console.error(error);
37- // return callback()
38- // }
25+ lambda . getFunction ( { FunctionName : FUNCTION_NAME } , function ( err , data ) {
26+ /* istanbul ignore else */
27+ if ( err ) { // if the function does not already exist we create it.
28+ console . error ( 'upload lambda.getFunction error:' , err ) ;
29+ return lambda . createFunction ( createParams ( pkg ) , callback ) ;
30+ } else { // otherwise update the *existing* lambda function:
31+ return updateFunction ( pkg , callback ) ;
32+ }
33+ } ) ;
3934} ;
4035
4136function createParams ( pkg ) {
0 commit comments