serverless dynamodb streams and triggers

Example on how to configure dynamodb stream in serverless.yml

   functions:  
      dynamodb-trigger:
        handler: yourfunction.handler
        events:
          - stream:
              type: dynamodb
              batchSize: 1
              startingPosition: LATEST
              arn:
                Fn::GetAtt:
                  - MyDynamoDbTable
                  - StreamArn
        iamRoleStatements:
          - Effect: Allow
            Action: 
              - dynamodb:ListStreams
              - dynamodb:DescribeTable
              - dynamodb:UpdateItem
              - dynamodb:GetItem
            Resource: 
            - "Fn::Join": ["", ["arn:aws:dynamodb:" , {"Ref": "AWS::Region"}, ":", {"Ref": "AWS::AccountId"} , ":table/${self:provider.environment.MFA_DYNAMODB_TABLE}"] ]

    resources:
      Resources:
        MyDynamoDbTable:
          Type: 'AWS::DynamoDB::Table'
          DeletionPolicy: Delete
          Properties:
            AttributeDefinitions:
              -
                AttributeName: id
                AttributeType: S
            KeySchema:
              -
                AttributeName: id
                KeyType: HASH
            ProvisionedThroughput:
              ReadCapacityUnits: 1
              WriteCapacityUnits: 1
            TableName: ${self:provider.environment.MFA_DYNAMODB_TABLE}
            StreamSpecification:
              StreamViewType: NEW_IMAGE

We had the same problem. And the answer was basically that you couldn't. Or more precisely, you couldn't without having to destroy the Dynamo DB table every time. We built this plugin that allows you to connect it up. https://www.npmjs.com/package/serverless-dynamo-stream-plugin.

Our team creates Dynamo DB tables via ansible or terraform depending on the project, and then we use this plugin to wire it together.

We are maintaining this via our open source repo on github, so if you have any issues or suggestions, you can message me here or there. Hope this helps, as we are using it in our production code base now.


events: 
    - stream: arn:aws:dynamodb:us-west-2:xxxxxx:table/tableName/stream/2018-04-19T16:40:37.833

this is proper way to get the trigger to be created on dynamodb