Skip to content

terminate_workflow_execution async

terminate_workflow_execution(
    domain: DomainName,
    workflow_id: WorkflowId,
    *,
    config_overrides: Optional[AsyncSWFClientConfig] = None,
    run_id: Optional[WorkflowRunIdOptional] = None,
    reason: Optional[TerminateReason] = None,
    details: Optional[Data] = None,
    child_policy: Optional[ChildPolicy] = None,
) -> None

Records a WorkflowExecutionTerminated event and forces closure of the workflow execution identified by the given domain, runId, and workflowId. The child policy, registered with the workflow type or specified when starting this execution, is applied to any open child workflow executions of this workflow execution.

If the identified workflow execution was in progress, it is terminated immediately.

If a runId isn't specified, then the WorkflowExecutionTerminated event is recorded in the history of the current open workflow with the matching workflowId in the domain.

You should consider using RequestCancelWorkflowExecution action instead because it allows the workflow to gracefully close while TerminateWorkflowExecution doesn't.

Access Control

You can use IAM policies to control this action's access to Amazon SWF resources as follows:

  • Use a Resource element with the domain name to limit the action to only specified domains.

  • Use an Action element to allow or deny permission to call this action.

  • You cannot use an IAM policy to constrain this action's parameters.

If the caller doesn't have sufficient permissions to invoke the action, or the parameter values fall outside the specified constraints, the action fails. The associated event attribute's cause parameter is set to OPERATION_NOT_PERMITTED. For details and example IAM policies, see Using IAM to Manage Access to Amazon SWF Workflows in the Amazon SWF Developer Guide.

Parameters:

  • domain (DomainName) –

    The domain of the workflow execution to terminate.

  • workflow_id (WorkflowId) –

    The workflowId of the workflow execution to terminate.

  • run_id (Optional[WorkflowRunIdOptional], default: None ) –

    The runId of the workflow execution to terminate.

  • reason (Optional[TerminateReason], default: None ) –

    A descriptive reason for terminating the workflow execution.

  • details (Optional[Data], default: None ) –

    Details for terminating the workflow execution.

  • child_policy (Optional[ChildPolicy], default: None ) –

    If set, specifies the policy to use for the child workflow executions of the workflow execution being terminated. This policy overrides the child policy specified for the workflow execution at registration time or when starting the execution.

    The supported child policies are:

    • TERMINATE – The child executions are terminated.

    • REQUEST_CANCEL – A request to cancel is attempted for each child execution by recording a WorkflowExecutionCancelRequested event in its history. It is up to the decider to take appropriate actions when it receives an execution history with this event.

    • ABANDON – No action is taken. The child executions continue to run.

    A child policy for this workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default child policy was specified at registration time then a fault is returned.

Raises:

  • OperationNotPermittedFault –

    Returned when the caller doesn't have sufficient permissions to invoke the action.

  • UnknownResourceFault –

    Returned when the named resource cannot be found with in the scope of this operation (region or domain). This could happen if the named resource was never created or is no longer available for this operation.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_swf/_services/async_swf.py
async def terminate_workflow_execution(
    self,
    domain: "capo_swf.types.domain_name.DomainName",
    workflow_id: "capo_swf.types.workflow_id.WorkflowId",
    *,
    config_overrides: Optional[AsyncSWFClientConfig] = None,
    run_id: Optional[
        "capo_swf.types.workflow_run_id_optional.WorkflowRunIdOptional"
    ] = None,
    reason: Optional["capo_swf.types.terminate_reason.TerminateReason"] = None,
    details: Optional["capo_swf.types.data.Data"] = None,
    child_policy: Optional["capo_swf.types.child_policy.ChildPolicy"] = None,
) -> None:
    """<p>Records a <code>WorkflowExecutionTerminated</code> event and forces closure of the workflow execution identified by the given domain, runId, and workflowId. The child policy, registered with the workflow type or specified when starting this execution, is applied to any open child workflow executions of this workflow execution.</p> <important> <p>If the identified workflow execution was in progress, it is terminated immediately.</p> </important> <note> <p>If a runId isn't specified, then the <code>WorkflowExecutionTerminated</code> event is recorded in the history of the current open workflow with the matching workflowId in the domain.</p> </note> <note> <p>You should consider using <a>RequestCancelWorkflowExecution</a> action instead because it allows the workflow to gracefully close while <a>TerminateWorkflowExecution</a> doesn't.</p> </note> <p> <b>Access Control</b> </p> <p>You can use IAM policies to control this action's access to Amazon SWF resources as follows:</p> <ul> <li> <p>Use a <code>Resource</code> element with the domain name to limit the action to only specified domains.</p> </li> <li> <p>Use an <code>Action</code> element to allow or deny permission to call this action.</p> </li> <li> <p>You cannot use an IAM policy to constrain this action's parameters.</p> </li> </ul> <p>If the caller doesn't have sufficient permissions to invoke the action, or the parameter values fall outside the specified constraints, the action fails. The associated event attribute's <code>cause</code> parameter is set to <code>OPERATION_NOT_PERMITTED</code>. For details and example IAM policies, see <a href="https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html">Using IAM to Manage Access to Amazon SWF Workflows</a> in the <i>Amazon SWF Developer Guide</i>.</p>

    Args:
        domain: <p>The domain of the workflow execution to terminate.</p>
        workflow_id: <p>The workflowId of the workflow execution to terminate.</p>
        run_id: <p>The runId of the workflow execution to terminate.</p>
        reason: <p> A descriptive reason for terminating the workflow execution.</p>
        details: <p> Details for terminating the workflow execution.</p>
        child_policy: <p>If set, specifies the policy to use for the child workflow executions of the workflow execution being terminated. This policy overrides the child policy specified for the workflow execution at registration time or when starting the execution.</p> <p>The supported child policies are:</p> <ul> <li> <p> <code>TERMINATE</code> – The child executions are terminated.</p> </li> <li> <p> <code>REQUEST_CANCEL</code> – A request to cancel is attempted for each child execution by recording a <code>WorkflowExecutionCancelRequested</code> event in its history. It is up to the decider to take appropriate actions when it receives an execution history with this event.</p> </li> <li> <p> <code>ABANDON</code> – No action is taken. The child executions continue to run.</p> </li> </ul> <note> <p>A child policy for this workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default child policy was specified at registration time then a fault is returned.</p> </note>

    Raises:
        capo_swf.errors.operation_not_permitted_fault.OperationNotPermittedFault: <p>Returned when the caller doesn't have sufficient permissions to invoke the action.</p>
        capo_swf.errors.unknown_resource_fault.UnknownResourceFault: <p>Returned when the named resource cannot be found with in the scope of this operation (region or domain). This could happen if the named resource was never created or is no longer available for this operation.</p>
        capo_swf.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_swf.types.terminate_workflow_execution_input.TerminateWorkflowExecutionInput]",
    ) -> AsyncOperationResponse[None]:
        import capo_swf._operations.simple_workflow_service.terminate_workflow_execution

        (
            output,
            http_response,
        ) = await capo_swf._operations.simple_workflow_service.terminate_workflow_execution.async_terminate_workflow_execution(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TerminateWorkflowExecution")
    )
    input_: capo_swf.types.terminate_workflow_execution_input.TerminateWorkflowExecutionInput = {
        "domain": domain,
        "workflow_id": workflow_id,
    }
    if run_id is not None:
        input_["run_id"] = run_id
    if reason is not None:
        input_["reason"] = reason
    if details is not None:
        input_["details"] = details
    if child_policy is not None:
        input_["child_policy"] = child_policy

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output