This section describes how to use Kinesis Data Streams for Amazon DynamoDB tables with the Amazon DynamoDB console, the AWS Command Line Interface (AWS CLI), and the API.
Creating an active Amazon Kinesis
data stream
All of these examples use the Music
DynamoDB table that was created as part
of the Getting
started with DynamoDB tutorial.
To learn more about how to build consumers and connect your Kinesis data stream to other AWS services, see Reading data from Kinesis Data Streams in the Amazon Kinesis Data Streams developer guide.
Note
When you're first using KDS shards, we recommend setting your shards to scale up and down with usage patterns. After you have accumulated more data on usage patterns, you can adjust the shards in your stream to match.
-
Sign in to the AWS Management Console and open the Kinesis console at https://console.aws.amazon.com/kinesis/
. -
Choose Create data stream and follow the instructions to create a stream called
samplestream
. -
Open the DynamoDB console at https://console.aws.amazon.com/dynamodb/
. -
In the navigation pane on the left side of the console, choose Tables.
-
Choose the Music table.
-
Choose the Exports and streams tab.
-
(Optional) Under Amazon Kinesis data stream details, you can change the record timestamp precision from microsecond (default) to millisecond.
-
Choose samplestream from the dropdown list.
-
Choose the Turn On button.
Making changes to an active Amazon Kinesis
data stream
This section describes how to make changes to an active Kinesis Data Streams for DynamoDB setup by using the console, AWS CLI and the API.
AWS Management Console
-
Open the DynamoDB console at https://console.aws.amazon.com/dynamodb/
-
Go to your table.
-
Choose Exports and Streams.
AWS CLI
-
Call
describe-kinesis-streaming-destination
to confirm that the stream isACTIVE
. -
Call
UpdateKinesisStreamingDestination
, such as in this example:aws dynamodb update-kinesis-streaming-destination --table-name enable_test_table --stream-arn arn:aws:kinesis:us-east-1:12345678901:stream/enable_test_stream --update-kinesis-streaming-configuration ApproximateCreationDateTimePrecision=MICROSECOND
-
Call
describe-kinesis-streaming-destination
to confirm that the stream isUPDATING
. -
Call
describe-kinesis-streaming-destination
periodically until the streaming status isACTIVE
again. It typically takes up to 5 minutes for the timestamp precision updates to take effect. Once this status updates, that indicates that the update is complete and the new precision value will be applied on future records. -
Write to the table using
putItem
. -
Use the Kinesis
get-records
command to get the stream contents. -
Confirm that the
ApproximateCreationDateTime
of the writes have the desired precision.
Java API
-
Provide a code snippet that constructs an
UpdateKinesisStreamingDestination
request and anUpdateKinesisStreamingDestination
response. -
Provide a code snippet that constructs a
DescribeKinesisStreamingDestination
request and aDescribeKinesisStreamingDestination response
. -
Call
describe-kinesis-streaming-destination
periodically until the streaming status isACTIVE
again, indicating that the update is complete and the new precision value will be applied on future records. -
Perform writes to the table.
-
Read from the stream and deserialize the stream content.
-
Confirm that the
ApproximateCreationDateTime
of the writes have the desired precision.