Skip to content

Lambda client wrapper #13

@mwarman

Description

@mwarman

Describe the story

Create a Lambda client utility which serves as a wrapper around the AWS SDK LambdaClient. This should simplify the creation of the AWS SDK Lambda client and it should store the created instance as a singleton for reuse across Lambda function invocations.

The wrapper should provide invokeLambdaSync and invokeLambdaAsync helper functions which invoke a Lambda function synchronously or asynchronously respectively. Both helper functions should send a JSON payload to the target Lambda function.

The wrapper should provide a getter which returns the singleton instance of the LambdaClient.

Acceptance criteria

GIVEN the app initializes an instance of the Lambda client
WHEN no parameters are supplied to the initializer
THEN an instance of the client is created using the default configuration for the LambdaClient

WHEN the LambdaClientConfig is provided to the initializer
THEN the LambdaClient instance is constructed using the supplied configuration

WHEN the LambdaClient instances are constructed
THEN they are cached as singleton instances

GIVEN the invokeLambdaSync function is invoked
WHEN the singleton instance does not exist
THEN a LambdaClient instance is constructed with default configuration
AND the instance is cached as the singleton
AND the instance is used by the invokeLambdaSync function to synchronously invoke the target function
AND the response is examined for a FunctionError
AND the function logs and throws an Error if a problem occurs
AND the function returns the response payload if successful

WHEN the singleton instance already exists
THEN the existing singleton instance is used by the invokeLambdaAsync function

GIVEN the invokeLambdaAsync function is invoked
WHEN the singleton instance does not exist
THEN a LambdaClient instance is constructed with default configuration
AND the instance is cached as the singleton
AND the instance is used by the invokeLambdaAsync function to synchronously invoke the target function
AND the response is examined for a FunctionError
AND the function logs and throws an Error if a problem occurs

WHEN the singleton instance already exists
THEN the existing singleton instance is used by the invokeLambdaAsync function

Additional context

Add any other context about the story here.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions