AWS Step Functions 상태 머신이 삭제 중 상태에서 멈췄습니다. 다음 단계를 알고 싶습니다.
간략한 설명
DeleteStateMachine API 작업은 Step Functions 상태 머신과 상태 머신의 버전 및 별칭을 비동기적으로 삭제합니다. DeleteStateMachine을 호출하고 상태가 삭제 중으로 전환된 후에는 상태 머신의 삭제를 중지할 수 없습니다. 그러나 실행이 대기 상태에 있거나 작업이 응답을 기다리는 경우 상태 머신이 삭제 중에 멈출 수 있습니다.
상태 머신 삭제 프로세스는 머신이 표준 또는 익스프레스 워크플로를 따르는지 여부에 따라 달라집니다. 일반적으로 표준 워크플로를 사용하는 상태 머신에서는 삭제가 중단되며, 다음과 같은 오류와 함께 실행이 실패합니다.
{"Type": "ExecutionFailed", "ExecutionFailedEventDetails": {"Error": States.Runtime", "Cause": "State machine testing-delete has been deleted."}}
해결 방법
삭제 중 상태에서 멈춘 표준 워크플로 상태 머신을 삭제하려면 다음 단계를 완료하십시오.
- 실행 중인 모든 실행을 나열합니다.
- 실행 중인 모든 실행을 중지합니다.
다음 예제 Python 코드는 실행을 중지합니다.
참고: 명령에서 EXAMPLE_ARN을 상태 머신의 ARN으로 바꾸십시오.
sf = boto3.client('stepfunctions')
runningExecutions = sf.list_executions(
stateMachineArn='EXAMPLE_ARN',
statusFilter='RUNNING')
executions = runningExecutions['executions']
if not executions:
print("No running executions")
else:
for exec in executions:
try:
executionArn = exec['executionArn']
response = sf.stop_execution(executionArn=executionArn)
except Exception as err:
print(f" Couldn't stop an execution due to the following error : {err=}")
print("All running executions have been aborted.")
참고: 익스프레스 워크플로가 있는 상태 머신은 ListeExecutions 및 StopExecutions API를 지원하지 않습니다.
상태 머신이 실수로 삭제되지 않도록 보호
Step Functions에서는 상태 머신을 백업할 수 없지만 다음 방법을 사용하면 상태 머신을 보호할 수 있습니다.