• Use this decorator to make your lambda handler itempotent. You need to provide a peristance layer to store the idempotency information. At the moment we only support DynamodbPersistenceLayer.

    Parameters

    Returns ((target, propertyKey, descriptor) => PropertyDescriptor)

      • (target, propertyKey, descriptor): PropertyDescriptor
      • Parameters

        • target: unknown
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns PropertyDescriptor

    Example

    import {
    DynamoDBPersistenceLayer,
    idempotentLambdaHandler
    } from '@aws-lambda-powertools/idempotency';
    import type { LambdaInterface } from '@aws-lambda-powertools/commons';

    class MyLambdaFunction implements LambdaInterface {
    ⁣@idempotent({ persistenceStore: new DynamoDBPersistenceLayer() })
    async handler(event: unknown, _context: unknown) {
    return "Hello World";
    }
    }
    export myLambdaHandler new MyLambdaFunction();
    export const handler = myLambdaHandler.handler.bind(myLambdaHandler);

    Similar to decoratoring a handler you can use the decorator on any other function.

    Example

    import {
    DynamoDBPersistenceLayer,
    idempotentFunction
    } from '@aws-lambda-powertools/idempotency';
    import type { LambdaInterface } from '@aws-lambda-powertools/commons';

    class MyClass implements LambdaInterface {
    public async handler(event: unknown, _context: unknown) {
    for(const record of event.records){
    await this.process(record);
    }
    }

    ⁣@idemptent({ persistenceStore: new DynamoDBPersistenceLayer() })
    public async process(record: Record<stiring, unknown>) {
    // do some processing
    }
    }

    See

Generated using TypeDoc