Skip to content

create_microvm_auth_token

create_microvm_auth_token(
    microvm_identifier: MicrovmIdentifier,
    expiration_in_minutes: PositiveInteger,
    allowed_ports: ListOfPortSpecification,
    *,
    config_overrides: Optional[LambdaMicrovmsClientConfig] = None,
) -> CreateMicrovmAuthTokenResponse

Creates an authentication token for accessing a running MicroVM. The token grants access to the specified ports on the MicroVM endpoint.

Parameters:

  • microvm_identifier (MicrovmIdentifier) –

    The ID of the MicroVM to create an authentication token for.

  • expiration_in_minutes (PositiveInteger) –

    The duration in minutes before the authentication token expires. Maximum: 60 minutes.

  • allowed_ports (ListOfPortSpecification) –

    The list of port specifications that the authentication token grants access to on the MicroVM.

Raises:

Source code in docs_src/capo_lambda_microvms/_services/lambda_microvms.py
def create_microvm_auth_token(
    self,
    microvm_identifier: "capo_lambda_microvms.types.microvm_identifier.MicrovmIdentifier",
    expiration_in_minutes: "capo_lambda_microvms.types.positive_integer.PositiveInteger",
    allowed_ports: "capo_lambda_microvms.types.list_of_port_specification.ListOfPortSpecification",
    *,
    config_overrides: Optional[LambdaMicrovmsClientConfig] = None,
) -> "capo_lambda_microvms.types.create_microvm_auth_token_response.CreateMicrovmAuthTokenResponse":
    """<p>Creates an authentication token for accessing a running MicroVM. The token grants access to the specified ports on the MicroVM endpoint.</p>

    Args:
        microvm_identifier: <p>The ID of the MicroVM to create an authentication token for.</p>
        expiration_in_minutes: <p>The duration in minutes before the authentication token expires. Maximum: 60 minutes.</p>
        allowed_ports: <p>The list of port specifications that the authentication token grants access to on the MicroVM.</p>

    Raises:
        capo_lambda_microvms.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_lambda_microvms.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry the request later.</p>
        capo_lambda_microvms.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. Retry the request later.</p>
        capo_lambda_microvms.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by the service.</p>
        capo_lambda_microvms.errors.conflict_exception.ConflictException: <p>The request could not be completed due to a conflict with the current state of the resource.</p>
        capo_lambda_microvms.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_lambda_microvms.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lambda_microvms.types.create_microvm_auth_token_request.CreateMicrovmAuthTokenRequest]",
    ) -> OperationResponse[
        "capo_lambda_microvms.types.create_microvm_auth_token_response.CreateMicrovmAuthTokenResponse"
    ]:
        import capo_lambda_microvms._operations.lambda_microvms.create_microvm_auth_token

        output, http_response = (
            capo_lambda_microvms._operations.lambda_microvms.create_microvm_auth_token.create_microvm_auth_token(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_lambda_microvms.types.create_microvm_auth_token_response.CreateMicrovmAuthTokenResponse",
    ) -> dict[str, Any]:
        import capo_lambda_microvms.types.create_microvm_auth_token_response

        return capo_lambda_microvms.types.create_microvm_auth_token_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateMicrovmAuthToken", redact_output=_redact_output),
    )
    input_: capo_lambda_microvms.types.create_microvm_auth_token_request.CreateMicrovmAuthTokenRequest = {
        "microvm_identifier": microvm_identifier,
        "expiration_in_minutes": expiration_in_minutes,
        "allowed_ports": allowed_ports,
    }

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