Skip to content

Commit b33e556

Browse files
abetomoDeviaVir
authored andcommitted
Fix to use Proxy (#324)
* Replace async with Promise * Modify to arrow function * Modify from var to const * Add proxy-agent In addition, the following command was executed - npm update - yarn upgrade * Fix to use Proxy * Modify text (Because Proxy needs to write from 'http')
1 parent a412f99 commit b33e556

File tree

6 files changed

+473
-71
lines changed

6 files changed

+473
-71
lines changed

bin/node-lambda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const AWS_DLQ_TARGET_ARN = (function () {
8383
}
8484
return undefined
8585
})()
86+
const PROXY = process.env.PROXY || process.env.http_proxy || ''
8687

8788
program
8889
.command('deploy')
@@ -123,6 +124,7 @@ program
123124
.option('-D, --prebuiltDirectory [' + PREBUILT_DIRECTORY + ']', 'Prebuilt directory', PREBUILT_DIRECTORY)
124125
.option('-T, --deployTimeout [' + DEPLOY_TIMEOUT + ']', 'Deploy Timeout', DEPLOY_TIMEOUT)
125126
.option('-z, --deployZipfile [' + DEPLOY_ZIPFILE + ']', 'Deploy zipfile', DEPLOY_ZIPFILE)
127+
.option('-y, --proxy [' + PROXY + ']', 'Proxy server', PROXY)
126128
.action(function (prg) {
127129
lambda.deploy(prg)
128130
})

lib/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const packageJson = require(path.join(__dirname, '..', 'package.json'))
1010
const minimatch = require('minimatch')
1111
const zip = new (require('node-zip'))()
1212
const dotenv = require('dotenv')
13+
const proxy = require('proxy-agent')
1314
const ScheduleEvents = require(path.join(__dirname, 'schedule_events'))
1415

1516
const maxBufferSize = 50 * 1024 * 1024
@@ -792,6 +793,10 @@ Lambda.prototype._deployToRegion = function (program, params, region) {
792793
aws.config.httpOptions.timeout = parseInt(program.deployTimeout)
793794
}
794795

796+
if (program.proxy) {
797+
aws.config.httpOptions.agent = proxy(program.proxy)
798+
}
799+
795800
aws.config.update(awsSecurity)
796801

797802
const lambda = new aws.Lambda({ apiVersion: '2015-03-31' })

0 commit comments

Comments
 (0)