Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 41 additions & 38 deletions lib/aws.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
'use strict'

const aws = require('aws-sdk')
const proxy = require('proxy-agent')

module.exports = {
sdk: aws,
updateConfig (config, region) {
const awsSecurity = { region }

if (config.profile) {
aws.config.credentials = new aws.SharedIniFileCredentials({
profile: config.profile
})
} else {
awsSecurity.accessKeyId = config.accessKey
awsSecurity.secretAccessKey = config.secretKey
}

if (config.sessionToken) {
awsSecurity.sessionToken = config.sessionToken
}

if (config.deployTimeout) {
aws.config.httpOptions.timeout = parseInt(config.deployTimeout)
}

if (config.proxy) {
aws.config.httpOptions.agent = proxy(config.proxy)
}

if (config.endpoint) {
aws.config.endpoint = config.endpoint
}

aws.config.update(awsSecurity)
}
}
// TODO:
// Support these option settings in SDK v3
//
// 'use strict'
//
// const aws = require('aws-sdk')
// const proxy = require('proxy-agent')
//
// module.exports = {
// sdk: aws,
// updateConfig (config, region) {
// const awsSecurity = { region }
//
// if (config.profile) {
// aws.config.credentials = new aws.SharedIniFileCredentials({
// profile: config.profile
// })
// } else {
// awsSecurity.accessKeyId = config.accessKey
// awsSecurity.secretAccessKey = config.secretKey
// }
//
// if (config.sessionToken) {
// awsSecurity.sessionToken = config.sessionToken
// }
//
// if (config.deployTimeout) {
// aws.config.httpOptions.timeout = parseInt(config.deployTimeout)
// }
//
// if (config.proxy) {
// aws.config.httpOptions.agent = proxy(config.proxy)
// }
//
// if (config.endpoint) {
// aws.config.endpoint = config.endpoint
// }
//
// aws.config.update(awsSecurity)
// }
// }
3 changes: 1 addition & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const process = require('process')
const path = require('path')
const os = require('os')
const aws = require(path.join(__dirname, 'aws'))
const { exec, execSync, execFile } = require('child_process')
const fs = require('fs-extra')
const klaw = require('klaw')
Expand Down Expand Up @@ -957,7 +956,7 @@ they may not work as expected in the Lambda environment.

async _deployToRegion (program, params, region, buffer) {
// sdk v3 todo: Migration of aws.updateConfig.
aws.updateConfig(program, region)
// aws.updateConfig(program, region)
const config = { region }

console.log('=> Reading event source file to memory')
Expand Down
Loading
Loading