Serverless DynamoDB Client Plugin
serverless-dynamodb-client is an abandoned Serverless Framework plugin designed to simplify interaction with AWS DynamoDB, providing a consistent API for both local DynamoDB instances and the AWS cloud service. Released as version `0.0.2` and last updated over 7 years ago, it was built specifically for Serverless Framework `0.5.x`. This package provides convenience wrappers for the AWS SDK's `DynamoDB` and `DynamoDB.DocumentClient` classes, automatically configuring them to point to a local DynamoDB instance (specifically on port 8000) when `serverless-dynamodb-local` is active, or to AWS otherwise. Due to its age and reliance on an extremely old version of the Serverless Framework, it is not compatible with modern Serverless setups (v1.x and above) and should not be used in new projects.
Common errors
-
Plugin 'ServerlessDynamodbClient' not found.
cause The Serverless Framework version being used (e.g., v1.x, v2.x, v3.x) is incompatible with this ancient plugin's registration method, which was designed for Serverless 0.5.x.fixThis plugin is deprecated and abandoned. Migrate to direct AWS SDK usage or a modern, actively maintained DynamoDB plugin compatible with your Serverless Framework version. -
connect ECONNREFUSED 127.0.0.1:8000
cause During local development, the `serverless-dynamodb-local` service is either not running, or it is running on a port other than the default `8000`, which this plugin expects.fixEnsure that `serverless-dynamodb-local` is installed and properly configured to start on port `8000` (e.g., via `serverless dynamodb install` and `serverless dynamodb start`) before invoking your Lambda functions locally.
Warnings
- breaking This plugin is designed exclusively for Serverless Framework 0.5.x and is completely incompatible with all modern versions (1.x and above). Attempting to use it with newer Serverless versions will result in critical failures and prevent deployment or local execution.
- deprecated The `serverless-dynamodb-client` package is effectively abandoned, with its last update occurring over 7 years ago. It has not received updates to support newer Node.js versions, AWS SDK changes, or modern Serverless Framework architecture, making it a severe security and compatibility risk.
- gotcha For local development, this plugin requires `serverless-dynamodb-local` to be running on its default port `8000`. The plugin does not support custom port configurations, which can lead to connection issues if your local DynamoDB is running on a different port.
Install
-
npm install serverless-dynamodb-client -
yarn add serverless-dynamodb-client -
pnpm add serverless-dynamodb-client
Imports
- dynamodb.raw
const dynamodb = require('serverless-dynamodb-client'); const rawClient = dynamodb.raw; - dynamodb.doc
const dynamodb = require('serverless-dynamodb-client'); const docClient = dynamodb.doc;
Quickstart
const dynamodb = require('serverless-dynamodb-client');
const rawClient = dynamodb.raw;
module.exports.listTables = async (event) => {
try {
// Ensure that serverless-dynamodb-local is running on port 8000 for local testing
const data = await rawClient.listTables().promise();
console.log("DynamoDB Tables:", data.TableNames);
return {
statusCode: 200,
body: JSON.stringify({
message: 'Successfully listed DynamoDB tables (see console)',
tables: data.TableNames,
}),
};
} catch (error) {
console.error("Error listing tables:", error);
return {
statusCode: 500,
body: JSON.stringify({
message: 'Failed to list DynamoDB tables',
error: error.message,
}),
};
}
};