question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configure DynamoDB stream locally

See original GitHub issue

I’m trying to trigger a lambda to update an Elastic Search instance whenever changes are made to DynamoDB. I have the stream set up in my serverless.yaml file, and when I deploy it, the lambda is triggered. However, when I run this with serverless-offline, the function is not triggered.

Here is my serverless.yaml

service: my-service

plugins:
  - serverless-dynamodb-local
  - serverless-offline

custom:
  tableName: "dynamodb-${self:provider.stage}"
  dynamodb:
    start:
      migrate: true

provider:
  name: aws
  runtime: nodejs6.10
  stage: dev
  region: ca-central-1
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
        - dynamodb:DescribeStream
        - dynamodb:GetRecords
        - dynamodb:GetShardIterator
        - dynamodb:ListStreams
      Resource:
        - { "Fn::GetAtt": ["DynamoDbTable", "Arn" ] }

functions:
  # Request that should trigger function
  add:
    handler: handler.add
    events:
      - http:
          path: api/add
          method: POST
  # Function that should be triggered
  updateIndices:
    handler: handler.updateIndices
    events:
      - stream:
          type: dynamodb
          arn:
            Fn::GetAtt:
              - DynamoDbTable
              - StreamArn
          startingPosition: LATEST
          batchSize: 1
          enabled: true

resources:
  Resources:
    DynamoDbTable:
      Type: "AWS::DynamoDB::Table"
      DeletionPolicy: Delete
      Properties:
        TableName: ${self:custom.tableName}
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        StreamSpecification:
          StreamViewType: NEW_AND_OLD_IMAGES
    ElasticSearchInstance:
      Type: "AWS::Elasticsearch::Domain"
      Properties:
        EBSOptions:
          EBSEnabled: true
          VolumeType: gp2
          VolumeSize: 10
        ElasticsearchClusterConfig:
          InstanceType: t2.small.elasticsearch
          InstanceCount: 1
          DedicatedMasterEnabled: false
          ZoneAwarenessEnabled: false
        ElasticsearchVersion: "6.0"

Is what I’m trying to do possible with serverless-dynamodb-local? Or is there more configuration that needs to be added to fire this function locally?

Thanks for the help!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
matttowerssonoscommented, Apr 24, 2018

+1 here. @rehrumesh Were you ever able to find out more?

0reactions
mydeen1989commented, May 5, 2022

Hi, I am also facing the same issue. I have tried the below plugins

   1. serverless-offline-dynamodb-streams
2. serverless-plugin-offline-dynamodb-stream

I am able see the data persisted in dynamodb local but the streams is not triggered. I am using serverless 3.0 framework.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DynamoDB local usage notes - AWS Documentation
Discover important tips for using and running DynamoDB locally on your computer. ... If you're using DynamoDB Streams, the rate at which shards...
Read more >
Stream support for local dynamodb? - Stack Overflow
Start DynamoDB local with java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -inMemory -sharedDb; Navigate to http://localhost: ...
Read more >
A complete guide on DynamoDB with a tutorial on how to set ...
To setup DynamoDB locally, you have to follow certain steps. This might seem complicated at once. But if you carefully follow all the...
Read more >
How to run DynamoDB Local and Offline - Complete Guide
Make sure you have Docker installed. · Create a file called docker-compose. · First, make sure you have Java Runtime Environment (JRE) version...
Read more >
Configure DynamoDB stream locally · Issue #151 - GitHub
I have the stream set up in my serverless.yaml file, and when I deploy it, the lambda is ... Configure DynamoDB stream locally...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found