Hey guys! I’m starting with Pulumi and I’m struggl...
# getting-started
b
Hey guys! I’m starting with Pulumi and I’m struggling with the concepts of stacks or how to organize the code for each stack. I understand that each stack could represent a environment (e.g. staging, production). Let’s assume I have a staging & a production environment. On production I have 2 web server & 1 database-server. On staging I have only 1 web server & 1 database-server. Do I have to make a variable “instances-count” in the yaml file and make a for-loop in the code and use this variable or what is the best practice to archive this? Additional question: What would I do if I have a component which is only used in one of these two environments? Thank you! 🙂
d
b
Thank you 🙂 I’ll check it 🙂
s
To address your other question, you can use Pulumi’s
config
object to retrieve values from the stack configuration. You can then use those values in your Pulumi program (to control a loop, for example).
b
Okay, thank you guys! To be honest, the example didn’t really help me. I also took a look at the repository of this series and found some Kubernetes configurations. The level for a newbie like me is a bit to high in this example 🙊
s
@brash-salesclerk-15704 Thanks for letting me know. If you don’t mind me asking, what part was too in-depth for a new user? Your feedback will help me improve this article and others like it.
b
Hi @salmon-account-74572, there is too much text to read and too little code 🙈 That’s is the interesting part for me in this blog series: Addressing the need for multiple environments But there is no code. Even in the documentation only the concepts are explained, but there is also no “real-life” example code on how to make multiple environments work. The step-by-step tutorials from DigitialOcean are really awesome (example) I’m really missing a “real-life” tutorial for a basic three-tier setup with different environments. Maybe that’s too specific for my use case.
Please don’t get me wrong. This is not meant personally 🙂