Step 4 - Enable DynamoDB Streams

Now that we have an AWS Lambda function created to process the DynamoDB Streams records, we need to enable the DynamoDB Stream on the logfile table. In the following step we will connect the stream with the function.

We will enable the stream on the logfile table. When a stream is enabled you can choose whether DynamoDB copies the new item, or the old item, or both old and new items, or just the partition and sort keys of an item that has been created, updated, or deleted. For more information on the different options you can review the documentation on StreamSpecification , which lists the options as follows: NEW_IMAGEOLD_IMAGENEW_AND_OLD_IMAGES, or KEYS_ONLY.

Enable DynamoDB Streams for the logfile table with the NEW_IMAGE, which includes “The entire item, as it appears after it was modified, is written to the stream.” according to the documentation linked above.

aws dynamodb update-table --table-name 'logfile' --stream-specification StreamEnabled=true,StreamViewType=NEW_IMAGE

Get the full ARN for DynamoDB Streams in the response. We will need this for the next step.

aws dynamodb describe-table --table-name 'logfile' --query 'Table.LatestStreamArn' --output text

The output will look like the following

arn:aws:dynamodb:<REGION>:<ACCOUNTID>:table/logfile/stream/2018-10-27T02:15:46.245

Note the ARN for use in the next step.