https://pulumi.com logo
#getting-started
Title
# getting-started
b

bitter-postman-91441

02/15/2024, 9:26 PM
If i have a single tenant application with multiple environments and customers whats the best way to handle this in pulumi. I think there's 2 approaches 1. A new stack for each customer and environment ie. pulumi stack init CustomerA.Test 2. A stack for Dev/Test/Prod and inside the yaml file a list of customers that can just be looped over in code. Any opinions on which approach is best or if theres another one im missing? There is no requirement for different customers to have different config/infra components
s

salmon-account-74572

02/15/2024, 10:25 PM
I'd recommend a separate stack for each combination of customer + environment:
Copy code
CustomerA-dev
CustomerA-test
CustomerA-prod
CustomerB-test
CustomerB-prod
CustomerC-prod
This ensures that each combination of customer + environment has its own independent state and cannot affect other combinations. To help with operations, use Automation API to manage the stacks.
l

little-cartoon-10569

02/15/2024, 10:26 PM
Yes, I think looping over customers in code isn't likely to be a good idea. Remember that everything in a stack gets deployed/updated at the same time; you're very unlikely to want to update all your customers at the same time. Therefore, stack-per-customer is the way to go.
b

bitter-postman-91441

02/15/2024, 10:30 PM
Great, thanks both. Our overall goal is to allow a developer to create these stacks without any input from us, we basically want to prompt them for a customername and nothing else. Would the automation API be the thing to look at for that kind of thing? Also interested in how we can do the same with our argo repo using outputs from pulumi. Ie we create a database and need to get the connection string into a new values file for that customer in our argo repo. Automation API or some glue code in a pipeline? Sorry if thats too big a question and thanks again!
l

little-cartoon-10569

02/15/2024, 10:34 PM
automation-api would be great if you wanted to put a UI / CLI over it. If you expect to work on the Pulumi code directly, then you don't really need it (though it opens up nice options if you do use it).
Glue code is fine.
pulumi --stack x output | grep outputname
or similar should work.
s

salmon-account-74572

02/15/2024, 10:38 PM
Basically +1 to everything @little-cartoon-10569 said :-)
b

bitter-postman-91441

02/15/2024, 10:42 PM
Great. Thank you both!
s

salmon-account-74572

02/15/2024, 10:44 PM
Happy to help!