Skip to content

Feature request: Custom Config - Lambda context #1302

@saragerion

Description

@saragerion

Use case

To help dealing with timeouts, users should be hable to bind the Lambda function's context with the Idempotency utility. The utility will then use the information regarding time remaining before timeout to handle idempotency record expiration internally.

Solution/User Experience

In some cases, like when making a custom function (aka not the handler) idempotent, customers might want to instantiate the config item within the scope, in this case they can pass the context directly to the constructor:

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

export const handler = (_event: unknown, context: Context) => {
  const config = new IdempotencyConfig({
    lambdaContext: context,
  });
};

In other (most) cases, customers will instantiate the config object outside of the handler, and then register the context by calling a method:

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

const config = new IdempotencyConfig({});

export const handler = (_event: unknown, context: Context) => {
  config.registerLambdaContext(context);
};

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