Skip to content

Commit 116cb75

Browse files
Fix for broken AWS resources (dherault#386)
* refactoring configuration of aws env vars to only occur with --noEnvironment * adding maintainer info
1 parent 62550da commit 116cb75

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"maintainers": [
2323
"Bilal Soylu (https://github.com/Bilal-S)",
2424
"Leonardo Alifraco (https://github.com/leonardoalifraco)",
25-
"Michael Staub (https://github.com/mikestaub)"
25+
"Michael Staub (https://github.com/mikestaub)",
26+
"Daniel Cottone <[email protected]> (https://github.com/daniel-cottone)"
2627
],
2728
"contributors": [
2829
"Adam Sweeting (https://github.com/adamelliottsweeting)",
@@ -87,7 +88,7 @@
8788
"Tuan Minh Huynh (https://github.com/tuanmh)",
8889
"Utku Turunc (https://github.com/utkuturunc)",
8990
"Vasiliy Solovey (https://github.com/miltador)",
90-
"Daniel Cottone (https://github.com/daniel-cottone)",
91+
"Daniel Cottone <[email protected]> (https://github.com/daniel-cottone)",
9192
"Jaryd Carolin (https://github.com/horyd)"
9293
],
9394
"license": "MIT",

src/index.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,19 @@ class Offline {
496496
let handler; // The lambda function
497497

498498
try {
499-
// This evict errors in server when we use aws services like ssm
500-
const baseEnvironment = {
501-
AWS_ACCESS_KEY_ID: 'dev',
502-
AWS_SECRET_ACCESS_KEY: 'dev',
503-
AWS_REGION: 'dev'
499+
if (this.options.noEnvironment) {
500+
// This evict errors in server when we use aws services like ssm
501+
const baseEnvironment = {
502+
AWS_ACCESS_KEY_ID: 'dev',
503+
AWS_SECRET_ACCESS_KEY: 'dev',
504+
AWS_REGION: 'dev'
505+
}
506+
process.env = _.extend({}, baseEnvironment);
507+
}
508+
else {
509+
Object.assign(process.env, this.service.provider.environment, this.service.functions[key].environment);
504510
}
505-
process.env = _.extend({}, baseEnvironment);
506-
if (!this.options.noEnvironment) Object.assign(process.env, this.service.provider.environment, this.service.functions[key].environment)
507-
Object.assign(process.env, this.originalEnvironment)
511+
Object.assign(process.env, this.originalEnvironment);
508512
handler = functionHelper.createHandler(funOptions, this.options);
509513
}
510514
catch (err) {

0 commit comments

Comments
 (0)