Skip to content

cancel_command

cancel_command(
    command_id: CommandId,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    instance_ids: Optional[InstanceIdList] = None,
) -> CancelCommandResult

Attempts to cancel the command specified by the Command ID. There is no guarantee that the command will be terminated and the underlying process stopped.

Parameters:

  • command_id (CommandId) –

    The ID of the command you want to cancel.

  • instance_ids (Optional[InstanceIdList], default: None ) –

    (Optional) A list of managed node IDs on which you want to cancel the command. If not provided, the command is canceled on every node on which it was requested.

Raises:

  • DuplicateInstanceId –

    You can't specify a managed node ID in more than one association.

  • InternalServerError –

    An error occurred on the server side.

  • InvalidCommandId –

    The specified command ID isn't valid. Verify the ID and try again.

  • InvalidInstanceId –

    The following problems can cause this exception:

    • You don't have permission to access the managed node.

    • Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.

    • SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.

    • The managed node isn't in a valid state. Valid states are: Running, Pending, Stopped, and Stopping. Invalid states are: Shutting-down and Terminated.

  • UnknownServiceError –

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

Source code in docs_src/capo_ssm/_services/ssm.py
def cancel_command(
    self,
    command_id: "capo_ssm.types.command_id.CommandId",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    instance_ids: Optional["capo_ssm.types.instance_id_list.InstanceIdList"] = None,
) -> "capo_ssm.types.cancel_command_result.CancelCommandResult":
    """<p>Attempts to cancel the command specified by the Command ID. There is no guarantee that the command will be terminated and the underlying process stopped.</p>

    Args:
        command_id: <p>The ID of the command you want to cancel.</p>
        instance_ids: <p>(Optional) A list of managed node IDs on which you want to cancel the command. If not provided, the command is canceled on every node on which it was requested.</p>

    Raises:
        capo_ssm.errors.duplicate_instance_id.DuplicateInstanceId: <p>You can't specify a managed node ID in more than one association.</p>
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.invalid_command_id.InvalidCommandId: <p>The specified command ID isn't valid. Verify the ID and try again.</p>
        capo_ssm.errors.invalid_instance_id.InvalidInstanceId: <p>The following problems can cause this exception:</p> <ul> <li> <p>You don't have permission to access the managed node.</p> </li> <li> <p>Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.</p> </li> <li> <p>SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.</p> </li> <li> <p>The managed node isn't in a valid state. Valid states are: <code>Running</code>, <code>Pending</code>, <code>Stopped</code>, and <code>Stopping</code>. Invalid states are: <code>Shutting-down</code> and <code>Terminated</code>.</p> </li> </ul>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.cancel_command_request.CancelCommandRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.cancel_command_result.CancelCommandResult"
    ]:
        import capo_ssm._operations.amazon_ssm.cancel_command

        output, http_response = (
            capo_ssm._operations.amazon_ssm.cancel_command.cancel_command(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CancelCommand")
    )
    input_: capo_ssm.types.cancel_command_request.CancelCommandRequest = {
        "command_id": command_id
    }
    if instance_ids is not None:
        input_["instance_ids"] = instance_ids

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output