3.0.0 • Published 7 months ago

serverless-aws-lambda-ddb-streams v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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
import { defineConfig } from "serverless-aws-lambda/defineConfig";
import { dynamoStream } from "serverless-aws-lambda-ddb-streams";

export default defineConfig({
  plugins: [dynamoStream(dynamoDbClientConfig, pluginOptions)],
});

DynamoDB Client Config

Configuration used to connect to DynamoDB Tables. By default the plugin uses following configuration:

{
  "endpoint": "http://127.0.0.1:8000",
  "region": "ddblocal",
  "credentials": { "accessKeyId": "test", "secretAccessKey": "test" }
}

If after connecting to the table, StreamEnabled is false, the plugin will try to enable it.

See docker-compose.yml to bootstrap local instance of DynamoDB using Docker.

Plugin Options

  • waitBeforeInit:
    An error will be thrown if after "waitBeforeInit" (in seconds) the plugin was not able to connect to the Table. default 25.
  • watchInterval:
    interval (in seconds) to check for new streamable records. default 2

Event Source Mapping

# serverless.yml
service: sls-project

frameworkVersion: "3"

plugins:
  - serverless-aws-lambda

custom:
  serverless-aws-lambda:
    configPath: ./config.default

provider:
  name: aws
  runtime: nodejs20.x
  region: eu-west-1

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:
    type: dynamodb
    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 TRIM_HORIZON)
    • DynamoDB Local dont works well with LATEST when multiple Tables are created.
    • As a workaround recreate a new table before starting the app.
  • āŒ startingPositionTimestamp
  • āœ… tumblingWindowInSeconds
  • āŒ parallelizationFactor
3.0.0

7 months ago

2.0.4

7 months ago

2.0.3

11 months ago

2.0.2

12 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago