Skip to content

Instantly share code, notes, and snippets.

@Tirke
Created December 9, 2019 20:02
Show Gist options
  • Save Tirke/82b962bb571e34af78f15037f39c4d63 to your computer and use it in GitHub Desktop.
Save Tirke/82b962bb571e34af78f15037f39c4d63 to your computer and use it in GitHub Desktop.
Kinesis + Lambda + Lambda Destinations on Failure (SQS Queue)
const Kinesis = require('aws-sdk/clients/kinesis')
const cli = new Kinesis({ region: 'eu-west-1' })
cli.getShardIterator({
StartingSequenceNumber: '49595535202406761165676766185764002510013872440053071874',
StreamName: 'test',
ShardId: 'shardId-000000000000',
ShardIteratorType: 'AT_SEQUENCE_NUMBER'
}).promise().then(async ({ ShardIterator }) => {
const rec = await cli.getRecords({ ShardIterator, Limit: 1 }).promise()
console.log(Buffer.from(rec.Records[0].Data).toString()) // => "/pfpfof(f
})
{
"requestContext": {
"requestId": "55b5b59c-6f44-4a26-8292-db43ed81693a",
"functionArn": "arn:aws:lambda:eu-west-1:xxxx:function:func-name",
"condition": "RetryAttemptsExhausted",
"approximateInvokeCount": 4
},
"responseContext": {
"statusCode": 200,
"executedVersion": "$LATEST",
"functionError": "Unhandled"
},
"version": "1.0",
"timestamp": "2019-12-09T19:36:44.572Z",
"KinesisBatchInfo": {
"shardId": "shardId-000000000000",
"startSequenceNumber": "49595535202406761165676766185764002510013872440053071874",
"endSequenceNumber": "49595535202406761165676766185764002510013872440053071874",
"approximateArrivalOfFirstRecord": "2019-12-09T19:03:40.680Z",
"approximateArrivalOfLastRecord": "2019-12-09T19:03:40.680Z",
"batchSize": 1,
"streamArn": "arn:aws:kinesis:eu-west-1:xxxxx:stream/test"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment