I'm using Pulumi to provision some EC2 instances b...
# aws
g
I'm using Pulumi to provision some EC2 instances behind a load balancer. When the EC2 config changes in a way that requires Pulumi to recreate the instances I'd like to be able to create the replacements first, wait for the health checks to pass and then destroy the old instances. I've been orchestrating this by hand by deleting the old instances from the Pulumi state and then provisioning the new ones, waiting until the health checks pass and then manually deleting the old instances. I see there's a
create_before_destroy
option but how would I wait on the health checks of the target group? Do I need to poll an AWS API outside of Pulumi for that? How can I hook the results of that polling back into Pulumi?
s
Would using an auto scaling group with min = max solve this problem?
You probably want that anyway since you are using userdata and would likely want an instance to be recreated if it were terminated e.g. b/c of a hardware failure.
g
Yeah that's a good point - I can look into that. Changing the instance type was a recent scenario where I had to do this by hand. Not sure if scaling groups would address that sort of config change though
s
g
Oh very nice. I'll dig into that. Thanks very much for the tip!
s
At the very least, an ASG with min = max = 1 should give you an improvement over static EC2 instances.