-
-
Save weizhou2273/4526154039ec54f326a9dabda0a5474d to your computer and use it in GitHub Desktop.
This file contains 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 boto3 | |
from moto import mock_kinesis | |
import credentials | |
import sys | |
from botocore.exceptions import ClientError | |
aws_key_id = credentials.aws['key_id'] | |
aws_key = credentials.aws['key'] | |
def create_stream(client, stream_name): | |
return client.create_delivery_stream( | |
DeliveryStreamName=stream_name , | |
S3DestinationConfiguration={ | |
'RoleARN': 'arn:aws:iam::52890735XXXX:role/firehose_delivery_role', | |
'BucketARN': 'arn:aws:s3:::project4capstones3', | |
'Prefix': stream_name+'//' | |
} | |
) | |
def main(search_name): | |
stream_name = search_name[0] | |
client = boto3.client('firehose', region_name='us-east-1', | |
aws_access_key_id=aws_key_id, | |
aws_secret_access_key=aws_key | |
) | |
try: | |
create_stream(client,search_name) | |
print 'Creating Kinesis stream... Please wait...' | |
time.sleep(60) | |
except: | |
pass | |
stream_status = client.describe_delivery_stream(DeliveryStreamName=stream_name) | |
if stream_status['DeliveryStreamDescription']['DeliveryStreamStatus'] == 'ACTIVE': | |
print "\n ==== KINESES ONLINE ====" | |
if __name__ == '__main__': | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment