Hi, folks! Can stacks be used to run different cod...
# general
a
Hi, folks! Can stacks be used to run different code paths (TypeScript in my case) or would I need different projects for that? Ideally I wouldn't have to query the stack name in my code and executed based on that, but if that's the only solution, I'd like to know.
b
Hi, What do you mean by different code paths here? Usually, stacks are for running multiple versions of the same infra but targetted towards different environments for example Projects are usually the place to run different types of infrastructure - an example would be project A runs your next working infrastructure and project B runs your database infrastructure
I hope that’s a little clearer
a
I'm still playing around with Pulumi and AWS, but my current use case is this: I'm setting up the build infrastructure that pulls some code from GitHub and builds a ZIP archive containing the code for an AWS Lambda and puts that ZIP into S3. However, I'm also defining the AWS Lambda inside my Pulumi code, and its definition references the artifact in S3 which will be missing the first time I run
pulumi up
. So, I thought I'd have to split the infrastructure code in two parts — one that sets up the build pipeline and one that defines the AWS Lambda. I presume I'd have to use two different projects for that — a build project and a lambda project, let's say — and have the S3 bucket's name output value exported for use within the Lambda project. Does that make sense? Thanks for your help.
b
That works perfectly - you can use a StackReference to do that across projects - so you are fine to split this up as you see fit
a
Nice! Thank you.