Decent way to update elastic CI stack using a pipeline

Hi currently we trigger a buildkite pipeline to update out Elastic CI stack

But it usually goes into a loop where cloudformation is unable to shutdown the agent due to the agent running
in this case the pipeline thats updating the elastic ci stack is the agent thats running
so it ends up in a deadlock

We would like to have suggestion on a decent way to update our Elastic CI stack through code

thanks

Hi @lewis good question :+1:

You could try creating a separate stack instead. That way you would create whole new instances that can start taking on jobs. Then after that stack is deployed, you could trigger another build or run a subsequent step that will destroy the old stack.
You could even do it sort of like a canary deployment where the new one only has 1 agent to begin with to ensure that it is going to work instead of cutting over and if something is wrong, you’ll be left with no agents