https://pulumi.com logo
Title
d

damp-school-17708

03/30/2021, 3:00 PM
Question, how do you handle 'conditional creation of resources'? I give you an example: we want only one codestar connetion with github and we want to share that across different stacks. ATM we do an if stack === dev { createNewCodestarConnection} else { getCodeStarConnection} Is there any better way? Thanks
b

bored-oyster-3147

03/30/2021, 3:01 PM
I would put shared resources in a different project and that way your main project can be the same on every stack and you can reference your shared resources with a StackReference
d

damp-school-17708

03/30/2021, 3:02 PM
interesting, we also trying to do monorepo, but I'll lookup stackreference and see if we can use it
b

bored-oyster-3147

03/30/2021, 3:03 PM
You could do conditional resources based on like configuration or input... but I wouldn't do it on stack name, conceptually stacks when given the same input should be identical IMO
d

damp-school-17708

03/30/2021, 3:06 PM
I think we are fighting a bit against that.. To be absolutely 'pure' we should probably use different aws accounts, we use stacks for environments, so dev, prod but also per engineer so everyone can do whatever they want. Unfortunately certain infrastracture bits in aws don't play well with this model (you want one vpc endpoint per vpc for instance, and other stuff)
b

bored-oyster-3147

03/30/2021, 3:10 PM
I don't see any reasons stacks couldn't use different aws accounts, that's what we do. We take in the desired account ID as an config value, and we have a root account with some shared resources
d

damp-school-17708

03/30/2021, 3:10 PM
yep I think that's the way - I just need to make that change
b

bored-oyster-3147

03/30/2021, 3:11 PM
it's a good change. But you'll need to get used to having multiple providers in your pulumi code and making sure that you're passing the correct provider around to the appropriate resources