Hello,
I’m struggling with trying to control the replacement order/cadence for my project:
I have two EC2 instances that I need to be replaced on change (such as AMI change, etc) one at a time in order to avoid downtime. From my understanding and observation, Terraform will only destroy everything first before it creates anything.
I’d like to destroy + create Instance1 before destroying + creating Instance2. I have tried using depends_on
but this will only implement the order of the destruction or creation but both instances will still be destroyed before they are then both created in whichever order.
Options I am aware of but are not currently viable:
- For my project, I am unable to utilize
terraform apply -replace
to target a resource or any other customization ofterraform apply
- changing to using AutoScalingGroups
-
create_before_destroy
(instances have network interfaces so this isn’t very feasible)
Any tips or help would be greatly appreciated! Thanks very much in advance for your time and consideration.