Skip to content

Commit e641116

Browse files
suleman-sohailSuleman Sohailder-eismann
authored
Stopped Executions before deleting step functions state machines (#1053)
* 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 <[email protected]> Co-authored-by: Philipp Trulson <[email protected]>
1 parent f1aff70 commit e641116

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

resources/sfn-statemachines.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ func ListSFNStateMachines(sess *session.Session) ([]Resource, error) {
4747
}
4848

4949
func (f *SFNStateMachine) Remove() error {
50+
params := &sfn.ListExecutionsInput{
51+
StateMachineArn: f.ARN,
52+
}
53+
54+
for {
55+
executions, execError := f.svc.ListExecutions(params)
56+
if execError != nil {
57+
break
58+
}
59+
for _, execs := range executions.Executions {
60+
61+
f.svc.StopExecution(&sfn.StopExecutionInput{
62+
ExecutionArn: execs.ExecutionArn,
63+
})
64+
}
65+
66+
if executions.NextToken == nil {
67+
break
68+
}
69+
params.NextToken = executions.NextToken
70+
}
5071

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

0 commit comments

Comments
 (0)