Skip to content

Feature request: add support for durable function in Idempotency Utility #7762

@ConnorKirk

Description

@ConnorKirk

Expected Behaviour

Idempotency utility detects it is a durable execution and invokes the handler

Current Behaviour

Raise IdemptoencyAlreadyInProgressError. Function will never terminate successfully. IdempotencyRecord in the persistance provider will be left in INPROGRESS state

Code snippet

from aws_durable_execution_sdk_python import (
    DurableContext,
    StepContext,
    durable_execution,
    durable_step,
)
from aws_durable_execution_sdk_python.config import Duration
from aws_lambda_powertools.utilities.idempotency import (
    DynamoDBPersistenceLayer,
    idempotent,
)

persistence_layer = DynamoDBPersistenceLayer(table_name="powertools-idempotency-table")


@durable_step
def greet_user(step_context: StepContext, name: str) -> str:
    """Generate a greeting."""
    return f"Hello {name}!"


@durable_execution
@idempotent(persistence_store=persistence_layer)
def lambda_handler(event: dict, context: DurableContext) -> str:
    """Simple durable function."""
    print(event, context)
    name = event.get("name", "World")
    greeting = context.step(greet_user(name))

    context.wait(duration=Duration.from_seconds(2))
    return greeting

Possible Solution

No response

Steps to Reproduce

  1. Create lambda function with durable config specified
  2. Invoke handler above
  3. Observe error

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.14

Packaging format used

PyPi

Debugging logs

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Working on it

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions