Skip to content

Instantly share code, notes, and snippets.

@kenoir
Created August 13, 2015 08:51
Show Gist options
  • Save kenoir/ac4bc9c89d0b748a96ea to your computer and use it in GitHub Desktop.
Save kenoir/ac4bc9c89d0b748a96ea to your computer and use it in GitHub Desktop.
Dump the contents of a kinesis stream into the console
require 'aws-sdk'
def dump_stream
kinesis = Aws::Kinesis::Client.new(region: 'eu-west-1')
iterator = kinesis.get_shard_iterator({
stream_name: "testStream",
shard_id: "shardId-000000000000",
shard_iterator_type: "LATEST",
})
i = iterator.shard_iterator
while(true) do
s = kinesis.get_records({shard_iterator: i})
i = s.next_shard_iterator
#puts "#{i}: #{s.records.length}"
s.records.each { |r| puts r.data }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment