gentle-monitor-55086
05/19/2021, 8:20 PM"if servers < desired { // deploy ec2}"
With the issue being on the second run pulumi would see we didn't define the first set of ec2's and go "oh well i should destroy those". My issue was that i was generating unique values for the ec2, storing it in the userdata, and then also saving those off to a DB... So even using protect
or ignoreChanges
it was (is) a pain to try and avoid re-generating / saving new values into the DB and required all sorts of shims and "clever"(breaks if you breathe on it) code.
I don't currently have an idea about the api and would like to do it the "right" waywitty-candle-66007
05/19/2021, 8:28 PMnum_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.gentle-monitor-55086
05/19/2021, 8:35 PMnum_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
witty-candle-66007
05/19/2021, 8:46 PMconst 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.