Skip to content

checkpoint_durable_execution

checkpoint_durable_execution(
    durable_execution_arn: DurableExecutionArn,
    checkpoint_token: CheckpointToken,
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    updates: Optional[OperationUpdates] = None,
    client_token: Optional[ClientToken] = None,
) -> CheckpointDurableExecutionResponse

Saves the progress of a durable function execution during runtime. This API is used by the Lambda durable functions SDK to checkpoint completed steps and schedule asynchronous operations. You typically don't need to call this API directly as the SDK handles checkpointing automatically.

Each checkpoint operation consumes the current checkpoint token and returns a new one for the next checkpoint. This ensures that checkpoints are applied in the correct order and prevents duplicate or out-of-order state updates.

Parameters:

  • durable_execution_arn (DurableExecutionArn) –

    The Amazon Resource Name (ARN) of the durable execution.

  • checkpoint_token (CheckpointToken) –

    A unique token that identifies the current checkpoint state. This token is provided by the Lambda runtime and must be used to ensure checkpoints are applied in the correct order. Each checkpoint operation consumes this token and returns a new one.

  • updates (Optional[OperationUpdates], default: None ) –

    An array of state updates to apply during this checkpoint. Each update represents a change to the execution state, such as completing a step, starting a callback, or scheduling a timer. Updates are applied atomically as part of the checkpoint operation.

  • client_token (Optional[ClientToken], default: None ) –

    An optional idempotency token to ensure that duplicate checkpoint requests are handled correctly. If provided, Lambda uses this token to detect and handle duplicate requests within a 15-minute window.

Raises:

  • InvalidParameterValueException –

    One of the parameters in the request is not valid.

  • KMSAccessDeniedException –

    Lambda couldn't decrypt the environment variables because KMS access was denied. Check the Lambda function's KMS permissions.

  • KMSDisabledException –

    Lambda couldn't decrypt the environment variables because the KMS key used is disabled. Check the Lambda function's KMS key settings.

  • KMSInvalidStateException –

    Lambda couldn't decrypt the environment variables because the state of the KMS key used is not valid for Decrypt. Check the function's KMS key settings.

  • KMSNotFoundException –

    Lambda couldn't decrypt the environment variables because the KMS key was not found. Check the function's KMS key settings.

  • ServiceException –

    The Lambda service encountered an internal error.

  • TooManyRequestsException –

    The request throughput limit was exceeded. For more information, see Lambda quotas.

  • UnknownServiceError –

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

Source code in docs_src/capo_lambda/_services/_lambda.py
def checkpoint_durable_execution(
    self,
    durable_execution_arn: "capo_lambda.types.durable_execution_arn.DurableExecutionArn",
    checkpoint_token: "capo_lambda.types.checkpoint_token.CheckpointToken",
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    updates: Optional[
        "capo_lambda.types.operation_updates.OperationUpdates"
    ] = None,
    client_token: Optional["capo_lambda.types.client_token.ClientToken"] = None,
) -> "capo_lambda.types.checkpoint_durable_execution_response.CheckpointDurableExecutionResponse":
    """<p>Saves the progress of a <a href="https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html">durable function</a> execution during runtime. This API is used by the Lambda durable functions SDK to checkpoint completed steps and schedule asynchronous operations. You typically don't need to call this API directly as the SDK handles checkpointing automatically.</p> <p>Each checkpoint operation consumes the current checkpoint token and returns a new one for the next checkpoint. This ensures that checkpoints are applied in the correct order and prevents duplicate or out-of-order state updates.</p>

    Args:
        durable_execution_arn: <p>The Amazon Resource Name (ARN) of the durable execution.</p>
        checkpoint_token: <p>A unique token that identifies the current checkpoint state. This token is provided by the Lambda runtime and must be used to ensure checkpoints are applied in the correct order. Each checkpoint operation consumes this token and returns a new one.</p>
        updates: <p>An array of state updates to apply during this checkpoint. Each update represents a change to the execution state, such as completing a step, starting a callback, or scheduling a timer. Updates are applied atomically as part of the checkpoint operation.</p>
        client_token: <p>An optional idempotency token to ensure that duplicate checkpoint requests are handled correctly. If provided, Lambda uses this token to detect and handle duplicate requests within a 15-minute window.</p>

    Raises:
        capo_lambda.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid.</p>
        capo_lambda.errors.kms_access_denied_exception.KMSAccessDeniedException: <p>Lambda couldn't decrypt the environment variables because KMS access was denied. Check the Lambda function's KMS permissions.</p>
        capo_lambda.errors.kms_disabled_exception.KMSDisabledException: <p>Lambda couldn't decrypt the environment variables because the KMS key used is disabled. Check the Lambda function's KMS key settings.</p>
        capo_lambda.errors.kms_invalid_state_exception.KMSInvalidStateException: <p>Lambda couldn't decrypt the environment variables because the state of the KMS key used is not valid for Decrypt. Check the function's KMS key settings.</p>
        capo_lambda.errors.kms_not_found_exception.KMSNotFoundException: <p>Lambda couldn't decrypt the environment variables because the KMS key was not found. Check the function's KMS key settings.</p>
        capo_lambda.errors.service_exception.ServiceException: <p>The Lambda service encountered an internal error.</p>
        capo_lambda.errors.too_many_requests_exception.TooManyRequestsException: <p>The request throughput limit was exceeded. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#api-requests">Lambda quotas</a>.</p>
        capo_lambda.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lambda.types.checkpoint_durable_execution_request.CheckpointDurableExecutionRequest]",
    ) -> OperationResponse[
        "capo_lambda.types.checkpoint_durable_execution_response.CheckpointDurableExecutionResponse"
    ]:
        import capo_lambda._operations.aws_gir_api_service.checkpoint_durable_execution

        output, http_response = (
            capo_lambda._operations.aws_gir_api_service.checkpoint_durable_execution.checkpoint_durable_execution(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_lambda.types.checkpoint_durable_execution_request.CheckpointDurableExecutionRequest",
    ) -> dict[str, Any]:
        import capo_lambda.types.checkpoint_durable_execution_request

        return (
            capo_lambda.types.checkpoint_durable_execution_request.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_lambda.types.checkpoint_durable_execution_response.CheckpointDurableExecutionResponse",
    ) -> dict[str, Any]:
        import capo_lambda.types.checkpoint_durable_execution_response

        return capo_lambda.types.checkpoint_durable_execution_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CheckpointDurableExecution",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_lambda.types.checkpoint_durable_execution_request.CheckpointDurableExecutionRequest = {
        "durable_execution_arn": durable_execution_arn,
        "checkpoint_token": checkpoint_token,
    }
    if updates is not None:
        input_["updates"] = updates
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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