NPM module - izara-middleware

From Izara Wiki
Jump to navigation Jump to search

Overview

Code that is shared by all services, including middleware code that executes at the beginning and end of each Lambda function and supporting code.

Middleware

The middleware that executes at the beginning and end of Lambda functions uses the Middy middleware module.

Middleware components

The below middleware components are executed in the below order:

captureCorrelationIds

..

integrationTests

Checks correlation ids for intTest-tag which should only exist if the request was initiated by the Integration Testing service.

If is part of an integration test then send a message to MsgOut queue with the event object.

sampleLogging

...

stopInfiniteLoop

...

logTimeout

...

httpHeaderNormalizer

...

jsonParseBody

...

urlEncodeBodyParser

...

validator

...

flattenRequest

...

Middleware: Debug Message

All services will have an SNS queue deployed named MsgOut, this middleware adds a message to this queue when the middleware's LOG_LEVEL is set to DEBUG at the start of the request with the functions received request properties and at the end of the function with the final response formatted in a standard way for Integration Testing to process.

Service requests

The middleware module includes wrapped objects that manage requests sent to other AWS services, this allows the middleware to add or adjust the request in a standard way, passing on values across the lifetime of a multi-resource action.

Services

The following services are supported:

DynamoDB

..

Firehose

..

Http (API Gateway)

..

Kinesis

..

Lambda

..

SNS

..

SQS

..

Step Functions

..

Other libraries

msgOutConfig

=== Standardize and validate messages to msgOut queue

  • When sending a message to the services msgOut queue use a library function to do this, ensuring that all messages to the queue have a configuration entry in Standard MsgIn MsgOut message config
  • Each msgOut message has a messageTag which matches a config entry

Send msgOut config to Message Config Manager service

  • Lambda function that sends all current message configs to Message Config Manager
  • Finds the Message Config Manager endpoint from an entry in Config table