22
33const path = require ( 'path' )
44const os = require ( 'os' )
5- const aws = require ( 'aws-sdk' )
5+ const aws = require ( path . join ( __dirname , 'aws' ) )
66const { exec, execSync, execFile } = require ( 'child_process' )
77const fs = require ( 'fs-extra' )
88const klaw = require ( 'klaw' )
99const packageJson = require ( path . join ( __dirname , '..' , 'package.json' ) )
1010const minimatch = require ( 'minimatch' )
1111const archiver = require ( 'archiver' )
1212const dotenv = require ( 'dotenv' )
13- const proxy = require ( 'proxy-agent' )
1413const ScheduleEvents = require ( path . join ( __dirname , 'schedule_events' ) )
1514const S3Events = require ( path . join ( __dirname , 's3_events' ) )
1615const S3Deploy = require ( path . join ( __dirname , 's3_deploy' ) )
@@ -822,51 +821,20 @@ they may not work as expected in the Lambda environment.
822821 } )
823822 }
824823
825- _awsConfigUpdate ( program , region ) {
826- const awsSecurity = { region : region }
827-
828- if ( program . profile ) {
829- aws . config . credentials = new aws . SharedIniFileCredentials ( {
830- profile : program . profile
831- } )
832- } else {
833- awsSecurity . accessKeyId = program . accessKey
834- awsSecurity . secretAccessKey = program . secretKey
835- }
836-
837- if ( program . sessionToken ) {
838- awsSecurity . sessionToken = program . sessionToken
839- }
840-
841- if ( program . deployTimeout ) {
842- aws . config . httpOptions . timeout = parseInt ( program . deployTimeout )
843- }
844-
845- if ( program . proxy ) {
846- aws . config . httpOptions . agent = proxy ( program . proxy )
847- }
848-
849- if ( program . endpoint ) {
850- aws . config . endpoint = program . endpoint
851- }
852-
853- aws . config . update ( awsSecurity )
854- }
855-
856824 _isFunctionDoesNotExist ( err ) {
857825 return err . code === 'ResourceNotFoundException' &&
858826 ! ! err . message . match ( / ^ F u n c t i o n n o t f o u n d : / )
859827 }
860828
861829 _deployToRegion ( program , params , region , buffer ) {
862- this . _awsConfigUpdate ( program , region )
830+ aws . updateConfig ( program , region )
863831
864832 console . log ( '=> Reading event source file to memory' )
865833 const eventSourceList = this . _eventSourceList ( program )
866834
867835 return Promise . resolve ( ) . then ( ( ) => {
868836 if ( this . _isUseS3 ( program ) ) {
869- const s3Deploy = new S3Deploy ( aws , region )
837+ const s3Deploy = new S3Deploy ( aws . sdk , region )
870838 return s3Deploy . putPackage ( params , region , buffer )
871839 }
872840 return null
@@ -880,13 +848,13 @@ they may not work as expected in the Lambda environment.
880848 }
881849 console . log ( params )
882850
883- const lambda = new aws . Lambda ( {
851+ const lambda = new aws . sdk . Lambda ( {
884852 region : region ,
885853 apiVersion : '2015-03-31'
886854 } )
887- const scheduleEvents = new ScheduleEvents ( aws , region )
888- const s3Events = new S3Events ( aws , region )
889- const cloudWatchLogs = new CloudWatchLogs ( aws , region )
855+ const scheduleEvents = new ScheduleEvents ( aws . sdk , region )
856+ const s3Events = new S3Events ( aws . sdk , region )
857+ const cloudWatchLogs = new CloudWatchLogs ( aws . sdk , region )
890858
891859 // Checking function
892860 return lambda . getFunction ( {
0 commit comments