Skip to content

Commit

Permalink
Don't unnecessarily re-run stop or terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Sep 22, 2023
1 parent 866fa9b commit 2bbd995
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,14 @@ async function reconcileMachine(state: Record<string, Instance>, machine: GetDes
if (machine.desiredState === GetDesiredStateResponse_MachineState.STOPPED) {
if (currentState === GetDesiredStateResponse_MachineState.PENDING) return
if (currentState === GetDesiredStateResponse_MachineState.DELETED) return
if (currentState === GetDesiredStateResponse_MachineState.STOPPING) return
console.log(`Stopping instance ${current.InstanceId}`)
await client.send(new StopInstancesCommand({InstanceIds: [current.InstanceId]}))
}

if (machine.desiredState === GetDesiredStateResponse_MachineState.DELETED) {
if (currentState === GetDesiredStateResponse_MachineState.PENDING) return
if (currentState === GetDesiredStateResponse_MachineState.DELETING) return
console.log(`Terminating instance ${current.InstanceId}`)
await client.send(new TerminateInstancesCommand({InstanceIds: [current.InstanceId]}))
}
Expand Down

0 comments on commit 2bbd995

Please sign in to comment.