流支持本地dynamodb?

时间:2016-01-19 17:22:25

标签: amazon-web-services amazon-dynamodb dynamo-local

我似乎无法在Dynamo db local中获得流支持,是否支持?我能找到它的唯一迹象是http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html#Tools.DynamoDBLocal.Differences

中的最后一个要点

使用dynamodb local,似乎忽略了StreamSpecification,因此在调用createTable或describeTable时没有LatestStreamArn

以下代码使用托管的dynamodb服务返回LatestStreamArn,但不返回本地的dynamodb:

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)
  }
})

1 个答案:

答案 0 :(得分:13)

我无法重现您的问题。我采取的步骤:

  1. here
  2. 下载DynamoDB Local
  3. 使用java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -inMemory -sharedDb
  4. 启动DynamoDB本地
  5. 导航至http://localhost:8000/shell/
  6. 粘贴下面的代码,然后单击播放按钮。我写的内容与上面的代码之间的唯一区别是我将ddb替换为dynamodb
  7. 当我这样做时,我得到一个非空且非空的LatestStreamArn 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 {
        // data.TableDescription.StreamSpecification and 
        // data.TableDescription.LatestStreamArn are undefined 
        // for dynamodb local
        console.log(data)
      }
    })