Created
September 14, 2018 18:24
-
-
Save seansullivan/ca1f1cbc49593dea27d42964a68b70eb to your computer and use it in GitHub Desktop.
Consume Kinesis Stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const STREAM_NAME = 'ssullivan-kinesis-fu'; | |
const REGION = 'us-west-2'; | |
const AWS = require('aws-sdk'); | |
const kinesis = new AWS.Kinesis({ region: REGION }); | |
const getRecordsFromShard = async (streamName) => { | |
const { Shards: [ { ShardId: shardId } ] } = await kinesis.listShards({ 'StreamName': streamName }).promise(); | |
const { ShardIterator: shardIterator } = await kinesis.getShardIterator({ | |
ShardId: shardId, | |
ShardIteratorType: 'TRIM_HORIZON', | |
StreamName: streamName | |
}).promise(); | |
return await kinesis.getRecords({ | |
ShardIterator: shardIterator, | |
Limit: 10 | |
}).promise(); | |
}; | |
getRecordsFromShard(STREAM_NAME) | |
.then(result => { | |
console.log(result); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment