Skip to content

Commit

Permalink
Stopped Executions before deleting step functions state machines (#1053)
Browse files Browse the repository at this point in the history
* Added Deletion protection disable feature in cognito user-pool

* Minor Changes

* nit

* spaces

* spaces 2

* stopping executions

* Stopped executiins

* nit

* Formatted

---------

Co-authored-by: Suleman Sohail <Suleman@Suleman-Sohail-SWE.local>
Co-authored-by: Philipp Trulson <der-eismann@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 24, 2023
1 parent f1aff70 commit e641116
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions resources/sfn-statemachines.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ func ListSFNStateMachines(sess *session.Session) ([]Resource, error) {
}

func (f *SFNStateMachine) Remove() error {
params := &sfn.ListExecutionsInput{
StateMachineArn: f.ARN,
}

for {
executions, execError := f.svc.ListExecutions(params)
if execError != nil {
break
}
for _, execs := range executions.Executions {

f.svc.StopExecution(&sfn.StopExecutionInput{
ExecutionArn: execs.ExecutionArn,
})
}

if executions.NextToken == nil {
break
}
params.NextToken = executions.NextToken
}

_, err := f.svc.DeleteStateMachine(&sfn.DeleteStateMachineInput{
StateMachineArn: f.ARN,
Expand Down

0 comments on commit e641116

Please sign in to comment.