Question, how do you handle 'conditional creation ...
# general
d
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
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
interesting, we also trying to do monorepo, but I'll lookup stackreference and see if we can use it
b
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
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
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
yep I think that's the way - I just need to make that change
b
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
254 Views