Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stopped Executions before deleting step functions state machines #1053

Merged
merged 13 commits into from
Aug 24, 2023
22 changes: 22 additions & 0 deletions resources/sfn-statemachines.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ func ListSFNStateMachines(sess *session.Session) ([]Resource, error) {
}

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

for{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please run go fmt to fix the formatting here?

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
Loading