""" Stop all swf currently rujnning in given swf_domain """ import boto3 import datetime import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) SWF_DOMAIN = 'dev_efedorov' swf_client = boto3.client('swf', region_name='us-east-1') executions_response = swf_client.list_open_workflow_executions( domain=SWF_DOMAIN, startTimeFilter={ 'oldestDate': datetime.datetime.now() - datetime.timedelta(hours=5) }, ) logger.info(executions_response) for execution in [e['execution'] for e in executions_response['executionInfos']]: workflow_id_ = execution['workflowId'] logger.warning(f'Stopping execution from workflow {workflow_id_}') swf_client.terminate_workflow_execution( domain=SWF_DOMAIN, workflowId=workflow_id_, runId=execution['runId'], )