Created
September 6, 2018 08:32
-
-
Save btel/05c044f1906fcfe855ffbdea5fcba086 to your computer and use it in GitHub Desktop.
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
| import boto | |
| from boto.kinesis.exceptions import ResourceInUseException | |
| import os | |
| import time | |
| if aws_profile: | |
| os.environ['AWS_PROFILE'] = aws_profile | |
| # connect to the kinesis | |
| kinesis = boto.kinesis.connect_to_region(region) | |
| def get_status(): | |
| r = kinesis.describe_stream(stream_name) | |
| description = r.get('StreamDescription') | |
| status = description.get('StreamStatus') | |
| return status | |
| def create_stream(stream_name): | |
| try: | |
| # create the stream | |
| kinesis.create_stream(stream_name, 1) | |
| print('stream {} created in region {}'.format(stream_name, region)) | |
| except ResourceInUseException: | |
| print('stream {} already exists in region {}'.format(stream_name, region)) | |
| # wait for the stream to become active | |
| while get_status() != 'ACTIVE': | |
| time.sleep(1) | |
| print('stream {} is active'.format(stream_name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment