Skip to content

terminate_session

terminate_session(
    session_id: SessionId, *, config_overrides: Optional[SSMClientConfig] = None
) -> TerminateSessionResponse

Permanently ends a session and closes the data connection between the Session Manager client and SSM Agent on the managed node. A terminated session can't be resumed.

Parameters:

  • session_id (SessionId) –

    The ID of the session to terminate.

Raises:

Source code in docs_src/capo_ssm/_services/ssm.py
def terminate_session(
    self,
    session_id: "capo_ssm.types.session_id.SessionId",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
) -> "capo_ssm.types.terminate_session_response.TerminateSessionResponse":
    """<p>Permanently ends a session and closes the data connection between the Session Manager client and SSM Agent on the managed node. A terminated session can't be resumed.</p>

    Args:
        session_id: <p>The ID of the session to terminate.</p>

    Raises:
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.terminate_session_request.TerminateSessionRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.terminate_session_response.TerminateSessionResponse"
    ]:
        import capo_ssm._operations.amazon_ssm.terminate_session

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TerminateSession")
    )
    input_: capo_ssm.types.terminate_session_request.TerminateSessionRequest = {
        "session_id": session_id
    }

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