Skip to content

Commit 4162446

Browse files
tiagogoncalves89daniel-cottone
authored andcommitted
Added support to noEnvironment flag (dherault#367)
* Added support for noEnvironment flag, serverless variables dont will be replaced by machine variables and avoid aws services like ssm to throw error when up the server * Released 3.19 version * now, environment variables replace serverless variables
1 parent f99d315 commit 4162446

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-offline",
3-
"version": "3.18.0",
3+
"version": "3.19.0",
44
"description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,15 @@ class Offline {
496496
let handler; // The lambda function
497497

498498
try {
499-
process.env = _.extend({}, this.service.provider.environment, this.service.functions[key].environment, this.originalEnvironment);
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'
504+
}
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)
500508
handler = functionHelper.createHandler(funOptions, this.options);
501509
}
502510
catch (err) {

0 commit comments

Comments
 (0)