Skip to content

Instantly share code, notes, and snippets.

@nexeh
Forked from kenoir/dump_stream.rb
Created August 9, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nexeh/feb9708a9ab026b4d865431f76b0b17c to your computer and use it in GitHub Desktop.
Save nexeh/feb9708a9ab026b4d865431f76b0b17c 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