1.1.3 ā¢ Published 11 months ago
serverless-aws-lambda-ddb-streams v1.1.3
Description
DynamoDB local Streams for serverless-aws-lambda
Installation
yarn add -D serverless-aws-lambda-ddb-streams
# or
npm install -D serverless-aws-lambda-ddb-streams
Usage
use serverless-aws-lambda's defineConfig to import this plugin
// config.js
const { defineConfig } = require("serverless-aws-lambda/defineConfig");
const { dynamoStream } = require("serverless-aws-lambda-ddb-streams");
module.exports = defineConfig({
plugins: [dynamoStream()],
});
Configuration
{
endpoint?: string; // default "http://localhost:8000"
region?: string; // based on your serverless.yml or default "eu-west-1"
waitBeforeInit?: number; // default 25 (secondes)
watchInterval?: number; // default 2 (secondes)
}
- endpoint:
local DynamoDB http endpoint - region: AWS Region for dynamodb client
- waitBeforeInit:
An error will be thrown if after "waitBeforeInit" the plugin was not able to connect to the Table. - watchInterval:
interval to check for new streamable records.
example:
module.exports = defineConfig({
plugins: [
dynamoStream({
endpoint: "http://localhost:8822",
waitBeforeInit: 40,
}),
],
});
# serverless.yml
service: sls-project
frameworkVersion: "3"
plugins:
- serverless-aws-lambda
custom:
serverless-aws-lambda:
configPath: ./config.default
provider:
name: aws
runtime: nodejs18.x
region: eu-west-3
functions:
myAwsomeLambda:
handler: src/handlers/lambda.default
events:
- stream:
arn: arn:aws:dynamodb:region:XXXXXX:table/Banana/stream/1970-01-01T00:00:00.000
batchSize: 3
Supported stream declarations
- stream:
arn: arn:aws:dynamodb:region:XXXXXX:table/Banana/stream/1970-01-01T00:00:00.000
- stream:
type: dynamodb
arn:
Fn::GetAtt: [MyDynamoDbTable, StreamArn]
- stream:
arn:
Fn::ImportValue: MyExportedDynamoDbStreamArnId
- stream:
arn:
Ref: MyDynamoDbTableStreamArn
- stream:
arn: !GetAtt dynamoTable.StreamArn
functions:
myAwsomeLambda:
handler: src/handlers/lambda.default
events:
- stream:
arn: arn:aws:dynamodb:region:XXXXXX:table/Banana/stream/1970-01-01T00:00:00.000
batchSize: 3
filterPatterns:
- eventName: [INSERT]
- dynamodb:
NewImage:
OrderId:
N:
- numeric: [">", 4]
Supported configurations
ā
supported
š planned
ā not planned
- ā batchSize
- ā batchWindow
- ā bisectBatchOnFunctionError
- ā destinations (requires AWS Local SNS and/or AWS Local SQS)
- ā enabled
- ā filterPatterns
- ā functionResponseType
- ā maximumRecordAgeInSeconds
- ā maximumRetryAttempts
- ā startingPosition (uses always "LATEST")
- ā startingPositionTimestamp
- ā tumblingWindowInSeconds
- ā parallelizationFactor