am I correct in thinking that `stack.setDefaultFun...
# help
s
am I correct in thinking that
stack.setDefaultFunctionProps()
is the same thing as
app.setDefaultFunctionProps()
, except it only applies to functions created within that stack?
t
I recently found out that if you use both they merge with each other
I think we need better naming on those functions, I assumed it fully override (eg environment variables)
but yes that's right
s
yeah.. that’s what I was thinking. so the app level sets defaults for all functions, and then stack level will override
or merge
perfect! that’s super handy
t
yeah you can call it multiple times to load up seevral environment variables.
s
and that’s exactly my use case 😄 I needed some global ones like
STAGE
and
SENTRY_DSN
, but then one stack in particular needed a GraphQL endpoint URL
t
awesome 👍🏽
f
wait guys.. i don’t think there’s a `stack.setDefaultFunctionProps()`😳
t
Ah you're right lol
s
there is though, I used it! 😄
t
wait...
s
and it worked as expected
t
I'm going crazy
s
Copy code
scope.setDefaultFunctionProps({
      bundle: {
        // sharp is a binary, and we have it in a Lambda layer, so exclude it
        externalModules: ['sharp'],
      },
      environment: {
        GRAPHQL_ENDPOINT_URL: props!.appSyncApi.url,
      },
    });
t
scope = app
f
scope
is the app
s
and that
GRAPHQL_ENDPOINT_URL
shows up in only the functions in that stack. lemme double-check
ohhh
t
I got confused because I saw a discussion about adding stack.setDefaultFunctionProps and though it existed
s
but look at this. here’s a function outside my MediaProcessor stack:
it doesn’t have the GraphQL URL
t
Is it possible that stack gets added before?
That function might get created before the other stack adds more defaults
s
hmm. yeah, this is the last stack out of the 3
sorry for the confusion! it would’ve been
this.setDefaultFunctionProps()
in the stack constructor, obviously
ok, so now I vote for this feature 😆
t
Seperately, was there a reason we named it
scope
instead of
app
@Frank?
I was confused about this when I was new
s
yeah, good point. I’m gonna rename that to
stack
in my stack definitions
er,
app
t
do you mean app 🙈
haha
s
what is wrong with me
f
You can technically create ur own Construct, and in there create ie.
sst.Api
, and the scope would be the outer Construct
You can technically create ur own wrapper (ie. if you are using the CodePipeline) and you create stacks in there, and the scope would be the Pipeline It’s not a use case I’ve come across often.
t
Ah I see
I'll make an issue for stack.setDefaultFunctionProps - I've seen this come up before
s
that would be awesome