Skip to content

LambdaClient.invoke

rboto-lambda==0.4.0 · Service index · Types

Model summary (excerpt): Invokes a Lambda Event Function. You can invoke a function synchronously (and wait for the response), or asynchronously. By default, Lambda invokes your function synchronously (i.e. the InvocationType is RequestResponse ). To invoke a function asynchronously, set InvocationType to Event . Lambda passes the ClientContext object to your function for synchronous invocations only. For synchronous...

Install and imports

python -m pip install "rboto[lambda]==0.4.0"
from rboto import LambdaClient
from rboto_lambda.types import (
    InvocationType,
    InvokeOutput,
    LogType,
)

Signature

async def invoke(
    *,
    function_name: str,
    invocation_type: InvocationType | None = None,
    log_type: LogType | None = None,
    client_context: str | None = None,
    durable_execution_name: str | None = None,
    payload: bytes | None = None,
    qualifier: str | None = None,
    tenant_id: str | None = None,
) -> InvokeOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
function_name Yes The name or ARN of the Lambda function, version, or alias. Name formats Function name – my-function (name-only), my-function:v1 (with alias). Function ARN – arn:aws:lambda:us-west-2:123456789012:function:my-function . Partial ARN – 123456789012:function:my-function . You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you...
invocation_type No Choose from the following options. RequestResponse (default) – Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API response includes the function response and additional data. Event – Invoke the function asynchronously. Send events that fail multiple times to the function's dead-letter queue (if one is configured). The API...
log_type No Set to Tail to include the execution log in the response. Applies to synchronously invoked functions only.
client_context No Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object. Lambda passes the ClientContext object to your function for synchronous invocations only. ClientContext is logged to CloudTrail if you turn on data events.
durable_execution_name No A unique name for the durable execution. If you invoke a durable function using a name that already exists with the same payload, Lambda returns the existing execution instead of creating a duplicate. If the payload differs, Lambda returns a DurableExecutionAlreadyStartedException error. If not specified, Lambda generates a unique identifier automatically. For more information, see Execution...
payload No The JSON that you want to provide to your Lambda function as input. The maximum payload size is 6 MB for synchronous invocations and 1 MB for asynchronous invocations. You can enter the JSON directly. For example, --payload '{ "key": "value" }' . You can also specify a file path. For example, --payload file://payload.json .
qualifier No Specify a version or alias to invoke a published version of the function.
tenant_id No The identifier of the tenant in a multi-tenant Lambda function.

Output

InvokeOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
status_code int Always present —
function_error str | None Always present —
log_result str | None Always present —
payload bytes | None Always present —
executed_version str | None Always present —
durable_execution_arn str | None Always present —

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

InvocationType, InvokeOutput, LogType

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_lambda.exceptions:

CodeArtifactUserDeletedError, CodeArtifactUserFailedError, CodeArtifactUserPendingError, DurableExecutionAlreadyStartedError, EC2AccessDeniedError, EC2ThrottledError, EC2UnexpectedError, EFSIOError, EFSMountConnectivityError, EFSMountFailureError, EFSMountTimeoutError, ENILimitReachedError, ENINotReadyError, InvalidParameterValueError, InvalidRequestContentError, InvalidRuntimeError, InvalidSecurityGroupIDError, InvalidSubnetIDError, InvalidZipFileError, KMSAccessDeniedError, KMSDisabledError, KMSInvalidStateError, KMSNotFoundError, ModeNotSupportedError, NoPublishedVersionError, RecursiveInvocationError, RequestTooLargeError, ResourceConflictError, ResourceNotFoundError, ResourceNotReadyError, RuntimeAliasDeletedError, RuntimeVersionDeletedError, S3FilesMountConnectivityError, S3FilesMountFailureError, S3FilesMountTimeoutError, SerializedRequestEntityTooLargeError, ServiceError, ServiceQuotaExceededError, SnapStartError, SnapStartNotReadyError, SnapStartRegenerationFailureError, SnapStartTimeoutError, SubnetIPAddressLimitReachedError, TooManyRequestsError, UnsupportedMediaTypeError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Example

Complete, type-checked service example. Replace its placeholders and configure credentials before running it.

import asyncio

from rboto import LambdaClient


async def main() -> None:
    client = LambdaClient(region="us-east-1")
    response = await client.invoke(function_name="my-function", payload=b'{"name":"Ada"}')
    if response.function_error:
        raise RuntimeError(response.function_error)
    print(response.status_code)
    print(response.payload)


if __name__ == "__main__":
    asyncio.run(main())

Service guide · Pinned model