How barchart/aws-lambda-suppressor works
This repository is a small Node.js library whose core purpose is to prevent duplicate AWS Lambda event processing. It is not a full application; it is a reusable package that plugs into a larger Lambda framework, especially @barchart/common-node-js.
1. Primary runtime boundary
- The package runs inside AWS Lambda execution environments.
- It receives Lambda event objects, derives a stable event identity, and uses DynamoDB as the deduplication store.
- The architectural boundary is between stateless Lambda handlers and a shared persistence layer used to coordinate suppression across invocations.
2. Main domain concept: event suppression
- The library treats an incoming event as “new” or “already processed.”
- If the event identity can be inserted into the store, processing is allowed.
- If the insert fails due to a conditional write conflict, the event is assumed to be a duplicate and should be suppressed.
3. Validator layer
- lib/dynamo/DynamoMessageValidator.js is the core implementation that performs the deduplication check against DynamoDB.
- lib/dynamo/DynamoLambdaValidator.js appears to specialize or adapt validation for Lambda-specific usage.
- These classes are the main integration point for application code, and they fit into a broader validation chain provided by @barchart/common-node-js.
4. Persistence layer
- lib/dynamo/tables/LambdaInvocationsTable.js encapsulates the DynamoDB table interaction details.
- The table is the durable registry of previously seen invocation identifiers.
- This separation keeps the validation logic distinct from the low-level storage schema and write mechanics.
5. Data flow through the system
- Lambda event arrives.
- A validator extracts or computes a unique identifier from the event.
- The identifier is written to DynamoDB using a conditional operation.
- Success means the invocation is first-seen; failure means a duplicate invocation and the handler should short-circuit.
6. Integration model
- The README describes the package as being used by instantiating a LambdaEventValidator, adding a DynamoMessageValidator, and plugging that validator into a LambdaHelper.
- That means this repository does not own the full Lambda handler lifecycle; it provides a focused validator component that another framework invokes.
7. Operational support scripts
- scripts/updates/environment-create.js suggests setup automation for provisioning or preparing the runtime environment.
- scripts/updates/set-expiration.js indicates lifecycle management around record expiry, likely to avoid unbounded growth in the deduplication table.
- These scripts are operational tooling around the core library rather than part of the runtime path.
8. Infrastructure assumptions
- DynamoDB is the only explicit external stateful dependency.
- The design relies on conditional writes, which is the key concurrency control mechanism for cross-invocation deduplication.
- Expiration/TTL handling is likely important because the deduplication key space is temporal, not permanent.
9. Build and release tooling
- gulpfile.js implies a build/release workflow managed through Gulp.
- buildspec.yml shows the project is built in AWS CodeBuild.
- The .releases directory indicates a changelog/release-note driven release process, which matters for package distribution but not runtime behavior.
10. Package shape
- package.json, .npmrc, and .npmignore confirm this is published as an npm package.
- The library is intended to be consumed by other Node.js projects rather than deployed standalone.
- The MIT license and public npm badge reinforce that it is a reusable infrastructure component.
11. Suggested architecture diagram focus
- Show a Lambda function invoking a validator layer.
- Show the validator writing to a DynamoDB “invocations” table with conditional put semantics.
- Show the duplicate-suppression decision returning to the Lambda handler.
- Optionally show setup/maintenance scripts as an offline operational lane for environment creation and record expiration.
12. What is intentionally missing
- There is no UI, API server, queue consumer framework, or multi-service backend here.
- The repository’s responsibility is narrow: deduplicate Lambda invocations through a DynamoDB-backed validator abstraction.
Main entry points: DynamoMessageValidator.js Message validator · LambdaInvocationsTable.js Invocations table · environment-create.js Ops scripts · DynamoLambdaValidator.js Lambda validator
Components 9
Lambda validation
In-process deduplication and validator integration used by Lambda handlers
- Lambda handler · Incoming AWS Lambda invocation that delegates duplicate checking to the library
- Event validator · Host-side validator chain that plugs the suppressor into a larger Lambda framework
- Lambda validator · Lambda-specific adapter that participates in the validation flow
lib/dynamo/DynamoLambdaValidator.js - Message validator · Core validator that computes identity and checks DynamoDB for duplicates
lib/dynamo/DynamoMessageValidator.js - Common Node JS · Host framework referenced by the package for validator and handler integration
Persistence
DynamoDB-backed registry of seen invocation identities
- Invocations table · Encapsulates the DynamoDB write path and table semantics for seen invocations
lib/dynamo/tables/LambdaInvocationsTable.js - DynamoDB · Conditional write store used to coordinate suppression across invocations
Operations
Offline setup, expiration, and release tooling
- Ops scripts · Environment creation and TTL/expiration maintenance utilities
scripts/updates/environment-create.js - Release notes · Changelog-driven package release artifacts and publishing history
.releases
Connections 10
- Lambda handler → Event validator: invokes · Handler delegates event processing to the validator chain
- Event validator → Lambda validator: includes · The framework wires in the Lambda-specific validator
- Lambda validator → Message validator: adapts · Lambda-specific validation is handled by the core message validator
- Message validator → Invocations table: checks · Core validation consults the invocations table for first-seen detection
- Invocations table → DynamoDB: writes · Table abstraction performs conditional persistence in DynamoDB
- Message validator → Lambda handler: suppresses · Duplicate detection returns a decision back to the handler
- Message validator → Common Node JS: integrates with · Validator is designed to plug into the broader Node.js Lambda framework
- Ops scripts → Invocations table: maintains · Operational scripts support setup and expiration management for stored records
- Ops scripts → DynamoDB: provisions · Environment creation and retention tasks act on the backing store
- Release notes → Common Node JS: packages · Release artifacts document and ship the library as a reusable npm package