1.1.3 ā€¢ Published 11 months ago

serverless-aws-lambda-ddb-streams v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 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
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
1.1.3

11 months ago

1.1.2

12 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago