https://serverless-stack.com/ logo
#help
Title
# help
j

Jon Holman

06/02/2022, 12:40 AM
I'm trying out the latest SST with the updated demo app. I already had a deployment of the demo app from many months ago, I was trying to update that deployment but its creating all new stacks. I think it would be good practice for me to figure out how to update existing stacks, rather than replace them. Or should I just try to keep the cognito user pool and the storage stack? Any tips? Thanks.
t

thdxr

06/02/2022, 12:40 AM
it's likely because of changes we made to the stack id
it's probably deploying new stacks called
<stage>-<app>-Stack
instead of
<stage>-<app>-stack
you can override the
id
in the index file per stack
j

Jon Holman

06/02/2022, 12:41 AM
Thanks, I'll give that a try.
BTW, I love the new syntax:
Copy code
app.stack(StorageStack).stack(ApiStack).stack(AuthStack).stack(FrontendStack);
could you recommend any reading to help me understand how that works?
t

thdxr

06/02/2022, 1:52 AM
I made a video explaining the thinking behind functional vs class:

https://www.youtube.com/watch?v=cqzgAJvUQCg&amp;t=5s

but are you curious about the underlying implementation?
j

Jon Holman

06/02/2022, 1:53 AM
I need to explore more, but I was curious how
use(...)
worked.
Thanks for the link, I'll check it out.
t

thdxr

06/02/2022, 1:55 AM
The typing for
use
is fairly simple, we take your input and return
ReturnType<typeof yourfunc>
j

Jon Holman

06/02/2022, 1:58 AM
I'm trying to understand how it gets the previous stacks in the chain from index.js and not just a new instance of the stack.
I watched the video. I think I understand it now, we're now defining stacks as functions, instead of classes. Now I'm wondering what if you need to pass two instances of a stack into another stack. Can you alias the function so that two instances can be passed in?
t

thdxr

06/02/2022, 1:33 PM
You can create a function that returns a function and do
Copy code
StackA = StackBuilder()
StackB = StackBuilder()
or define the stacks normally and call a common function
Copy code
function StackA(ctx) {
  return StackBuilder(ctx)
}

function StackB(ctx) {
  return StackBuilder(ctx)
}
where this pattern is weaker is fully dynamic stacks that aren't known at compile time. still possible but uglier
j

Jon Holman

06/02/2022, 1:34 PM
Thanks
t

thdxr

06/02/2022, 1:34 PM
in terms of getting the previous stacks, we just have a global object that keeps track of all initialized stacks
j

Jon Holman

06/02/2022, 1:37 PM
This is great. Thank you.
3 Views