In a monorepo setup, my understanding is your sugg...
# help
r
In a monorepo setup, my understanding is your suggestion is to have the sst.json in the root directory outside of the services correct? How do you then only work on a single service when you would have to have all the stacks defined in one index.ts? P.s loving SST and its community 🙂
t
hey you wouldn't have to have all stacks in one file, you can define them in seperate files and import them
an example of our new functional stack setup (released but not yet documented): https://github.com/serverless-stack/graphql-stack/blob/main/stacks/index.ts
r
Not sure i see any different to the setup minus the functional part? You are still defining everything in the
main
method right? I am sure i am missing something very simple 🙂
t
I meant the actual stacks are in other files
So yes we do recommend sticking to a single app and splitting it up with multiple stacks. Having multiple apps might make sense but it gets pretty unwieldy and we haven't seen the need to do that much even at larger scale
r
So i guess the question i am asking is if you dont want to work on an entire app (deploying everything per developer would be hundreds of services potentially), how would you just work on one stack?
i was kinda expecting something like
npx sst start <stackname>
a
I mean, index.js is a javascript file...you could read some env vars there and use them to decide which stacks to create
maybe a bit hacky, but it's what I was able to come up with 🙂
then in the package.json, you could do:
Copy code
"scripts": {
      "test": "sst test",
      "start": "sst start",
      "start-orders": "STACKS=billing,order,admin sst start",
      "start-usermgt": "STACKS=registration,profile,admin sst start",      "build": "sst build",
      "deploy": "sst deploy",
      "remove": "sst remove"
   },
and then read STACKS in index.js and use it to decide which stacks to create
just an idea
or if it's really just a single stack you want, do
STACK=myStack npx sst start
and then in index.js only create this stack when STACK has any value
r
thats an interesting idea which could def work thanks. I am a litle surprised noone else is asking this question which makes me wonder if I am just thinking about things wrong.
a
my own project isn't big enough yet that I had ever wished to be able to only start single stacks
r
yeah i am guessing that is likely true for most people
a
I don't think it's an unreasonable request to ask that npx sst start can also take a list of stacks to start, like deploy can
I'm not sure how easy it is to implement, but I'm not an sst developer
r
appreciate your responses they are really useful for the conversation thanks. I too think an option on the CLI would be great but as you mentioned there are work arounds.
f
Hey @Rob N, just to clarify, assume there are 10 stacks in the app, and someone ran
npx sst start stack1 stack2
. Is it that: • Live debug 2 stacks and deploy the other 8 stacks normally (ie. only Lambda functions in
stack1
and
stack2
are invoked locally); OR • Live debug 2 stacks and NOT deploy the other 8 stacks.
r
Hey @Frank thats actually very good question 🙂. I could see arguments for both options depending on your setup. Generally speaking our engineers usually use a centralised dev/staging stack for services they are not working on but I really guess its highly dependant on how large your application is as to which option would be best for your needs.
d
@thdxr How would we for example add tags to all stacks with functional approach. Currently we have a “BaseStack” that we extend and it’s there that we handle everything.
t
well since everything is just a function the simplest is to use a helper function
Copy code
function MyStack(ctx: StackContext) {
  useDefaults(ctx)
}
you can get fancy also and make something that supports this
Copy code
const MyStack = useDefaults(() => {
  
})
I prefer the first option since it's composable