Skip to content

Feature request: Custom Config - Idempotency key required #1295

@saragerion

Description

@saragerion

Use case

When using the Idempotency utility, users should be able to enforce that an idempotency key is required. When this requirement is expected and not satisfied, the utility should throw an IdempotencyKeyError.

Solution/User Experience

The throwOnNoIdempotencyKey key should be used in conjunction with the eventKeyJmesPath one:

import { IdempotencyConfig } from '@aws-lambda-powertools/idempotency';

const config = new IdempotencyConfig({
  eventKeyJmesPath: '[user.uid, order_id]',
  throwOnNoIdempotencyKey: true
});

Given the above, the following event payload will be OK:

{
    "user": {
        "uid": "BB0D045C-8878-40C8-889E-38B3CB0A61B1",
        "name": "Foo"
    },
    "order_id": 10000
}

while the one below will cause an IdempotencyKeyError to be thrown (notice :
that order_id is within the user key, and so it won't satisfy the JMESPath expression from above)

{
    "user": {
        "uid": "DE0D000E-1234-10D1-991E-EAC1DD1D52C8",
        "name": "Joe Bloggs",
        "order_id": 10000
    },
}

Reference: https://awslabs.github.io/aws-lambda-powertools-python/2.10.0/utilities/idempotency/#making-idempotency-key-required

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