This message was deleted.
# general
s
This message was deleted.
w
You can use Pulumi stacks to drive the different environments via the stack-specific configuration file. The ideas is that you have a project (i.e. the code) and then you instantiate different stacks for the different environments. So, in your “dev” config file you would have
num_desired_servers
set to 1 or whatever and in the “prod” config file this would be set to 5 or whatever. Pulumi then manages the stacks separately.
g
somehow i missed the stack referencing ( i was avoiding doing multiple stacks since it seemed like a pain to get the names of my DB's etc. into my other stacks etc. 🤦 ) However i'm not sure this would help for the server example... For that, i wanted to be able to say start a stack with say
num_desired_servers = 1
and then scale it up on another "up" command later to maybe 3.
I also wanted to be able to scale down as well.
I would just use
protect
but it seemed tedious to me to have to unprotect the servers to be able to destroy the stack
in hindsight it probably wouldn't have been that big of a deal
w
This sort of code:
Copy code
const instanceCount = config.getNumber("instanceCount");
for (let i = 0; i < instanceCount; i++) {
   // Create servers here
}
If the config file for, say the staging stack, has
instanceCount
set to, say, 2, this code will create 2 servers. Then later, if the config for staging is changed so that
instanceCount
is now set to, say, 3, Pulumi will create 1 more server and leave the original 2 servers as-is.
If the intent is to do the 2 servers and then add the 1 server as part of one “event” then the automation API may be helpful here since it allows you do this sort of orchestration. https://www.pulumi.com/docs/guides/automation-api/