Stream support for local dynamodb?
Asked Answered
C

1

20

I can't seem to get stream support working in dynamo db local, are they supported? The only indication I could find that they are, is the very last bullet point in the developer guide regarding local differences:

If you're using DynamoDB Streams, the rate at which shards are created might differ. In the DynamoDB web service, shard-creation behavior is partially influenced by table partition activity. When you run DynamoDB locally, there is no table partitioning. In either case, shards are ephemeral, so your application should not be dependent on shard behavior.

With dynamodb local, it appears that the StreamSpecification is ignored so there is no LatestStreamArn when calling createTable or describeTable

The following code returns LatestStreamArn with the managed dynamodb service but not dynamodb local:

ddb.createTable({
  TableName: 'streaming_test',

  AttributeDefinitions: [
    { AttributeName: 'id', AttributeType: 'S' }
  ],

  KeySchema: [
    { AttributeName: 'id', KeyType: 'HASH' }
  ],

  ProvisionedThroughput: {
    ReadCapacityUnits: 5,
    WriteCapacityUnits: 5
  },

  StreamSpecification: {
    StreamEnabled: true,
    StreamViewType: 'NEW_AND_OLD_IMAGES'
  }
}, function (err, data) {
  if (err) {
    console.log(err, err.stack)
  } else {
    // data.TableDescription.StreamSpecification and 
    // data.TableDescription.LatestStreamArn are undefined 
    // for dynamodb local
    console.log(data)
  }
})
Choline answered 19/1, 2016 at 17:22 Comment(0)
R
19

I am not able to reproduce your issue. Steps I took:

  1. Download DynamoDB Local from here
  2. Start DynamoDB local with java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -inMemory -sharedDb
  3. Navigate to http://localhost:8000/shell/
  4. Paste the code below and click the play button. The only difference between what I wrote and your code above is that I replaced ddb with dynamodb.

When I did this, I got a non-null and non-empty LatestStreamArn of arn:aws:dynamodb:ddblocal:000000000000:table/streaming_test/stream/2017-02-12T08:39:03.722.

dynamodb.createTable({
  TableName: 'streaming_test',

  AttributeDefinitions: [
    { AttributeName: 'id', AttributeType: 'S' }
  ],

  KeySchema: [
    { AttributeName: 'id', KeyType: 'HASH' }
  ],

  ProvisionedThroughput: {
    ReadCapacityUnits: 5,
    WriteCapacityUnits: 5
  },

  StreamSpecification: {
    StreamEnabled: true,
    StreamViewType: 'NEW_AND_OLD_IMAGES'
  }
}, function (err, data) {
  if (err) {
    console.log(err, err.stack)
  } else {
    console.log(data)
  }
})
Rumery answered 12/2, 2017 at 8:44 Comment(2)
I haven't been able to confirm whether this works but judging from the upvotes, this was helpful to a lot of other users. Accepted! ThanksCholine
I had the same problem with local dynamo, but I was using existing local table, created without stream specification. When I recreated the local table it worked with no problem.Incognizant

© 2022 - 2024 — McMap. All rights reserved.