def create_kinesis_stream(stream):
    """
    Creates our Kinesis stream
    """
    kinesis = boto.connect_kinesis()
    response = kinesis.create_stream(stream, 1)
    pause_until_kinesis_active(stream)
    print("Kinesis successfully created")
Esempio n. 2
0
def get_or_create_stream(stream_name, shard_count):
    stream=None
    try:
        stream=kinesis.describe_stream(streamName)
        print(json.dumps(stream,sort_keys=True,indent=2,separators=(',',':')))
    except ResourceNotFoundException as enfe:
        while(stream is None) or (stream['StreamStatus'] is not 'ACTIVE'):
            print('Could not find ACTIVE stream:0 trying to create.'.format(stream_name))
            stream=kinesis.create_stream(stream_name,shard_count)
            time.sleep(0.5)
    return stream
# Get our instance ID out of the metadata
instance_id = instance_metadata['instance-id']

# Use the instance ID as our stream name
stream_name = instance_id

# Use only one shard
shard_count = 1

try:
  # Connect to Kinesis
  kinesis = boto.connect_kinesis()

  # Create the stream for this instance ID
  kinesis.create_stream(stream_name, shard_count)
except boto.kinesis.exceptions.ResourceInUseException:
  # Stream has already been created, this can be safely ignored
  pass

tries = 0

# Try up to 10 times to open the stream
while tries < 10:
  tries += 1

  # Get the stream description
  response = kinesis.describe_stream(stream_name)

  # Is the stream active?
  if response['StreamDescription']['StreamStatus'] == 'ACTIVE':
Esempio n. 4
0
from boto import kinesis
kinesis = kinesis.connect_to_region("eu-west-1")
stream = kinesis.create_stream("BotoDemo", 1)
kinesis.describe_stream("BotoDemo")
kinesis.list_streams()