Skip to content

Feature request: DynamoDB persistence layer #1294

Closed
@saragerion

Description

@saragerion

Use case

This persistence layer is built-in, and you can either use an existing DynamoDB table or create a new one dedicated for idempotency state (recommended).

In scope

  • Ability to configure the persistence layer via constructor:
Parameter Required Default Description
tableName ✔️ Table name to store state
keyAttr id Partition key of the table. Hashed representation of the payload (unless sort_key_attr is specified)
expiryAttr expiration Unix timestamp of when record expires
inProgressExpiryAttr in_progress_expiration Unix timestamp of when record expires while in progress (in case of the invocation times out)
statusAttr status Stores status of the lambda execution during and after invocation
dataAttr data Stores results of successfully executed Lambda handlers
validationKeyAttr validation Hashed representation of the parts of the event used for validation
sortKeyAttr Sort key of the table (if table is configured with a sort key).
staticPkValue idempotency#{LAMBDA_FUNCTION_NAME} Static value to use as the partition key. Only used when sort_key_attr is set.
  • Ability to pass clientConfig or awsSdkV3Client to respectively configure the AWS SDK client of the persistence layer or pass a custom SDK client altogether
  • Handling errors and exceptions IdempotencyItemNotFound, IdempotencyInvalidStatus, IdempotencyInconsistentState
  • Handling scenario of execution happening in sequence and in parallel
  • Unit tests

Out of scope

Expected behaviour

  1. Payload ABCD is passed to the idempotent target
  2. Business logic calls the persistence layer to get or set a new record based on payload
  3. The persistence layer record based on the unique payload is marked as locked
  4. The idempotent target processes the payload
  5. The persistence layer record is updated with the result of this processing
  6. Payload ABCD is passed to the idempotent target (again)
  7. The idempotent target calls the persistence layer to get or set a new record based on payload
  • If the existing record has expired, the existing result & status of the previous idempotency record will be overwritten with the new in-progress record
  • If the existing record has not expired, the existing record's value will be used and returned

Solution/User Experience

See: https://awslabs.github.io/aws-lambda-powertools-python/2.7.1/utilities/idempotency/#persistence-layers

Alternative solutions

No response

Acknowledgment

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityidempotencyThis item relates to the Idempotency Utility

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions