2

I am using python, and want to configure the database connection based on whether the function is running offline or deployed to AWS.

Some examples use the environment variable 'IS_OFFLINE', but it doesn't seem to be set.

Was that feature replaced with something else, or only available in the js runtime? What's the right way to detect whether a function is being run offline?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
shader
  • 801
  • 1
  • 7
  • 25

2 Answers2

1

Try:

console.log(process.env.IS_OFFLINE)

https://www.serverless.com/plugins/serverless-offline#the-processenvis_offline-variable

For Python:

How to get environment from a subprocess?

Jason Mullings
  • 850
  • 14
  • 10
0

For Python, you can access the IS_OFFLINE flag by using this: os.environ['IS_OFFLINE']

Ju Li
  • 1