https://pulumi.com logo
#general
Title
# general
a

abundant-book-94104

11/08/2021, 11:27 PM
I am looking at how I structure our infrastructure within Pulumi. Is it right to have a single project with multiple stacks eg one stack to set up resource groups, another for networks, then for databases of various ilk and so on? The laternative is to have them in multiple projects, one for resource groups, one for networks, databases, key vaults and so on?
p

prehistoric-activity-61023

11/08/2021, 11:30 PM
You can structure it as you want but I think the common approach is to use different projects for different things like network, database etc. Stacks are used to distinguish different instances of the project (e.g. dev, staging, prod).
a

abundant-book-94104

11/08/2021, 11:31 PM
That was my feeling then I was concerned with how things interacted, so as long as I understand my dependencies to know the build order it should all be good
l

little-cartoon-10569

11/08/2021, 11:31 PM
Yes, this one. If you use different stacks to do different things, you need extra code with a load of "if (stack == "network) { ... }" code, and it gets awkward.
p

prehistoric-activity-61023

11/08/2021, 11:31 PM
That’s more in line how pulumi works because “the same code” (I used quotes cause you can do some conditional logic based on the stack values etc.) is used while managing different stacks of the given project.
@little-cartoon-10569 explained it right - it’s double but it’s gonna look weird 😉
plus it seems to be less reusable
keep in mind that if you create different projects, you’ll probably wanna use stack references so you can depend on some resources created in the “parent” project
a

abundant-book-94104

11/08/2021, 11:33 PM
thanks heaps, I shall continue the journey and happy to know I had gotten it right so far. I'll look into the stack references
p

prehistoric-activity-61023

11/08/2021, 11:33 PM
+ a very simple example illustrating the concept: https://github.com/pulumi/examples/tree/master/aws-py-stackreference
👍 1
2 Views