Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.env.IS_OFFLINE is always undefined #1

Open
gkylafas opened this issue Feb 1, 2017 · 0 comments
Open

process.env.IS_OFFLINE is always undefined #1

gkylafas opened this issue Feb 1, 2017 · 0 comments

Comments

@gkylafas
Copy link

gkylafas commented Feb 1, 2017

Scenario

Suppose you have configured plugins serverless-dynamodb-local, serverless-offline and serverless-dynamodb-client. Then, you execute commands

$ sls offline & [1]
$ sls invoke local -f function --path input.json [2]

Result

The AWS dynamodb instance will be used, not the local one.

Explanation

The reason is that:

  • command [1] sets environment variable IS_OFFLINE not to the parent shell but to the sls offline process
  • when command [2] is executed, it inherits the environment of the shell, which has no IS_OFFLINE defined. So, when require('serverless-dynamodb-client') is called, isOffline() always returns false.

Workaround

Execute

$ export IS_OFFLINE=true

before command [2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant