Should I be able to get hold of the IS_LOCAL env v...
# sst
r
Should I be able to get hold of the IS_LOCAL env var inside the stack definition file? The reason I ask is that I want to extend the timeout when running locally for debug purposes.
f
hmm… that’s a good point. Lemme put that in.
For now, i guess u can set it manually
IS_LOCAL=true npm run start
r
yeah, thanks again
t
I've been using scope.local
Is that not the same thing? Been using it to make certain resources (prod aurora) not be created locally
r
Didn’t know about that
f
@thdxr I forgot about it. It’s not well documented either.
What do you guys think? Should we unify this and expose an
IS_LOCAL
env var in the stack definition?
On a second thought,
scope.local
is probably the better approach than
process.env.IS_LOCAL
. We should stick with accessing a flag like this through CDK code. We need to do a better job documenting
scope.local
r
I guess the challenge with scope.local vs process.env.IS_LOCAL is that you only have access to scope.local within the stack, if for some reason you wanted to perform some logic based on this outside of the stack you wouldn’t have access to it. I’m struggling for a use case where that’d be the case, thought I’d mention in case others can
t
I pass that scope around to a bunch of helper functions
f
Hey guys, weirdly I couldn’t stop thinking about this lol. So after reading up on some “best practice” guidelines on environment variables, it seems we should expose a config as environment variable if its value is dependent on the environment (sst start local environment in this case).
So with v0.13.0, you can access
process.env.IS_LOCAL
inside ur CDK code.
As a side note, this release also has built-in support for
.env
. Here’s a link to the doc with some examples https://docs.serverless-stack.com/working-locally#environment-variables
j