Our plan is to have a monorepo with a bunch of sta...
# help
s
Our plan is to have a monorepo with a bunch of stacks in it. Stack A is considered the "core" services like auth, DB, buckets, etc. Stacks B, C, and D are other things that depend on the core, like API and other microservices. Is there some way to set up
yarn start --stage devname
so that it only spins up a specific stack for them to work on, and will properly reference Stack A in a totally different stage?
t
Can you tell me more about why you'd like to have developers not get their own version of every part of the infrastructure?
s
it’s likely I just haven’t thought this through 100% yet.. 😉 but it seems like it’s just overkill. Cognito, Aurora, buckets.. there’d be duplicates of each of those for every developer. which also means that there would be a whole set of secrets & SSM params for every dev. not to mention, the first deploy would take 20 mins thanks to CloudFront distributions. but that would probably be a one-time thing it sounds like a hassle to maintain.
not to mention the cost of an Aurora DB for every dev
t
Got it. I've been opting to give every developer their own full setup especially, it will be slow on first deploy but it's a one time thing + easy clean up when you destroy the stack. Full environments helps them run tests that properly wipe + seed data without stepping on each other. Also you can make it uses Aurora serverless in local dev if you aren't using it in production which should help with the cost. You can disable certain resources if
scope.local
is true to speed up things as well That said if you don't feel like that's worth I have an idea for what you can do but haven't fully tested it. Basically you can override the stack name on only the non-shared stacks like so:
Copy code
new SharedStack(app, "shared")
  new Stack(app, "individual", {
    stackName: `${app.stage}-${developer_name}`,
  })
This should make it so everyone deploys the same stack except for the individual stack. Set stage to
dev
or something and pass in
developer_name
maybe through an environment variable
s
interesting.. trying to wrap my head around it. what prevents
SharedStack
from getting deployed? what if I did something like this:
Copy code
export default function main(app: <http://sst.App|sst.App>): void {
  // Set default runtime for all functions
  app.setDefaultFunctionProps({
    runtime: 'nodejs14.x',
    tracing: Tracing.DISABLED,
  });

  if (['dev', 'prod'].includes(app.stage)) {
    new CoreStack(app, 'core');
  }
  new APIStack(app, 'api');
}
so when a dev runs
yarn start --stage $(whoami)
, the core stack won’t get deployed
t
It won't be deployed but I imagine you'll want to pass values from it to the APIStack
My suggestion requires everyone to use the same
dev
stage but then the
APIStack
would get a name that's unique to them, forcing a unique deployment per developer
s
ahh gotcha. I like that approach too
I’ll need to have a think on all this. thanks for being a sounding board
t
np!
s
I’m pretty sure I’ve decided to go with 100% isolation. so, each dev deploys their own stack.. and in fact each dev has their own AWS account too
t
That's what I do, aws account per dev
It's a nice way to get good billing info too
s
definitely
so now I just have to figure out how, when a dev runs the front end locally, they set that up to use their own API endpoints & Lambda functions.. and secondly, how their deployed PR branch accesses their stack
But bringing this functionality to the base StaticSite as well