So, here’s what I need to do. I need to make a change to a an AWS elb target group that requires recreating it. In order to avoid taking any downtime, I need the changes to be done in the following order:
- Create the new target group (aws_lb_target_group)
- Add the target group to the list of target groups for an auto scaling group (aws_autoscaling_group)
- Change the aws_lb_listener to use the new target group rather than the old one
- remove the old target group from the auto scaling group
- delete the old target group
create_before_destroy on the target group, I can almost get, but I’m not sure how to split up steps 2 and 4, instead of changing the autoscaling group to remove and add the target groups at the same time.
Ideally, I’d also like to wait until the instances from the scale group are marked as healthy in the target group before doing step 3.
This is a specific case that I recently ran into, but there are other similar scenarios I’ve encountered in the past, where avoiding downtime needs finer control over the order of operations than terraform seems to give.
Does anyone have suggestions on how to deal with these kinds of changes?