35 KiB
35 KiB
4 Kinesis Data Streams & Firehose
Przebieg ćwiczenia
- Stwórz Data Stream z wykorzystaniem boto3 / AWS console (GUI)
- wygeneruj testowe dane do streama
- odczytaj dane ze streama (ShardIterator)
- Stwórz Kinesis Firehose Stream i podepnij pod niego utworzony wcześniej Data Stream jako source. Skonfiguruj buffor size = 1Mb buffor time = 60s
- wygeneruj 10000 wiadomości i sprawdź czy dane ładowane są do S3
Pamiętaj aby po skończonych ćwiczeniach usunąć wszystkie obiekty
Uwaga !!! poniższy skrypt tworzy obiekty w regionie HongKong ! Na końcu skryptu jest funkcja tear_down_all() która usuwa testowy bucket, bazę Glue i Kinesis Data Streams czyli wszystkie obiekty które były stworzone w kodzie.
import boto3
REGION = "ap-east-1"
session_kwargs = {
"aws_access_key_id":"",
"aws_secret_access_key":"",
"aws_session_token":"",
"region_name": REGION
}
session = boto3.Session(**session_kwargs)
kinesis_client = session.client("kinesis")
STREAM_NAME = 'uam-test'
kinesis_client.create_stream(
StreamName=STREAM_NAME,
ShardCount=1
)
{'ResponseMetadata': {'RequestId': 'dd209b3a-57d1-b862-8a48-bc194546845a', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'dd209b3a-57d1-b862-8a48-bc194546845a', 'x-amz-id-2': 'k78aY4x6wCDEXo6kL76yEG64tV2ct9TQxM76Bfy345CJgSaVdfDJsjlr1jzNnpRxVk2qc+G9L42xZbmYrx/mivAFMWoek7Si', 'date': 'Sat, 20 Jun 2020 15:01:55 GMT', 'content-type': 'application/x-amz-json-1.1', 'content-length': '0'}, 'RetryAttempts': 0}}
kinesis_client.list_streams()["StreamNames"]
['uam-test']
response = kinesis_client.put_record(
StreamName=STREAM_NAME,
Data=b'{"col1" : "this is my test json data"}',
PartitionKey='1'
)
print(response)
{'ShardId': 'shardId-000000000000', 'SequenceNumber': '49608139280302835973846909376978574930250627257427034114', 'ResponseMetadata': {'RequestId': 'c4858035-fc96-5621-93ed-a71b8bbdb95f', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'c4858035-fc96-5621-93ed-a71b8bbdb95f', 'x-amz-id-2': 'Z8hEKLIaCne7YPLWuDMTiFcAt7s1HJvfENE/2Oj7ARnuzjOsVNj+QyHpuIbM0tMucp7YZxLq2M65Xy/bgyyYeI2T5eJviuYA', 'date': 'Sat, 20 Jun 2020 15:02:06 GMT', 'content-type': 'application/x-amz-json-1.1', 'content-length': '110'}, 'RetryAttempts': 0}}
response = kinesis_client.describe_stream(StreamName=STREAM_NAME)
print(response)
[1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) [1;32m<ipython-input-3-f9ad17c57d0b>[0m in [0;36m<module>[1;34m[0m [1;32m----> 1[1;33m [0mresponse[0m [1;33m=[0m [0mkinesis_client[0m[1;33m.[0m[0mdescribe_stream[0m[1;33m([0m[0mStreamName[0m[1;33m=[0m[0mSTREAM_NAME[0m[1;33m)[0m[1;33m[0m[1;33m[0m[0m [0m[0;32m 2[0m [0mprint[0m[1;33m([0m[0mresponse[0m[1;33m)[0m[1;33m[0m[1;33m[0m[0m [1;31mNameError[0m: name 'kinesis_client' is not defined
shard_ids = []
stream_name = None
if response and 'StreamDescription' in response:
stream_name= response['StreamDescription']['StreamName']
for shard_id in response['StreamDescription']['Shards']:
shard_id = shard_id['ShardId']
shard_iterator = kinesis_client.get_shard_iterator(StreamName=stream_name, ShardId = shard_id, ShardIteratorType="TRIM_HORIZON")
shard_ids.append({'shard_id' : shard_id ,'shard_iterator' : shard_iterator['ShardIterator'] })
shard_ids
[1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) [1;32m<ipython-input-4-bfebdd8c4299>[0m in [0;36m<module>[1;34m[0m [0;32m 1[0m [0mshard_ids[0m [1;33m=[0m [1;33m[[0m[1;33m][0m[1;33m[0m[1;33m[0m[0m [0;32m 2[0m [0mstream_name[0m [1;33m=[0m [1;32mNone[0m[1;33m[0m[1;33m[0m[0m [1;32m----> 3[1;33m [1;32mif[0m [0mresponse[0m [1;32mand[0m [1;34m'StreamDescription'[0m [1;32min[0m [0mresponse[0m[1;33m:[0m[1;33m[0m[1;33m[0m[0m [0m[0;32m 4[0m [0mstream_name[0m[1;33m=[0m [0mresponse[0m[1;33m[[0m[1;34m'StreamDescription'[0m[1;33m][0m[1;33m[[0m[1;34m'StreamName'[0m[1;33m][0m[1;33m[0m[1;33m[0m[0m [0;32m 5[0m [1;33m[0m[0m [1;31mNameError[0m: name 'response' is not defined
sh = shard_iterator["ShardIterator"]
sh
'AAAAAAAAAAHfJPwIwOEqHzQIjn90snM/nPs4zZARsJlXPyGlUTbvU+T5cdGvXzb54qetks+heTq/ttfFlehkcLGr27CpkPNDn2A9NHYc1w+3VjLIBmNKTLJlHnCjjFCwgqksrs1mUQVli12hZjy6wZXhGualZUI//H2BxRwKqH/Pf2Zk9S6KSbeJFDm0boV2COPqB3wZ21axe8lWXJVJAfjMgPacIU6K'
tries = 0
limit = 100
result = []
while tries < 10:
tries += 1
response_get_rec = kinesis_client.get_records(ShardIterator = sh , Limit = limit)
shard_iterator = response_get_rec['NextShardIterator']
break
response_get_rec
{'Records': [{'SequenceNumber': '49608139280302835973846909376978574930250627257427034114', 'ApproximateArrivalTimestamp': datetime.datetime(2020, 6, 20, 17, 2, 6, 976000, tzinfo=tzlocal()), 'Data': b'{"col1" : "this is my test json data"}', 'PartitionKey': '1'}], 'NextShardIterator': 'AAAAAAAAAAEgmwgBEgaauGNF/YzN5S+FcuWOWZZMledH4BR7CLiGD9iYYL4z+eLK7NaTQTHTAlSFEYm6N6vtjdFcTl8ibGJGKnuQthZiMgCfolA1FAAoWmLHvI0slHvZx1oWLfdApD8robDWj3zX/2d4zOzj1P9xz/+Xo8/YFdCXd0ENfUNxI7MhzZUGamw09rXa8Y0sDunFpkLy7msr5vjURGjr+xrf', 'MillisBehindLatest': 0, 'ResponseMetadata': {'RequestId': 'e580a084-b06e-ca24-b2e8-87b6c745255a', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'e580a084-b06e-ca24-b2e8-87b6c745255a', 'x-amz-id-2': '/zy9vbX4wzEuqd7TZ959MQcL0OzB9kPQ3TSfrtEIIpI1IvubKb7OgnxYhxiWIZpvPWbtzXO5x0r+eO6+A8wR+bn0v8khnlpL', 'date': 'Sat, 20 Jun 2020 15:02:10 GMT', 'content-type': 'application/x-amz-json-1.1', 'content-length': '489'}, 'RetryAttempts': 0}}
[x["SequenceNumber"] for x in response_get_rec["Records"] ]
['49608122819498384072835111163875039160761192199284064258']
response_get_rec["Records"]
[{'SequenceNumber': '49608122819498384072835111163875039160761192199284064258', 'ApproximateArrivalTimestamp': datetime.datetime(2020, 6, 20, 4, 13, 11, 39000, tzinfo=tzlocal()), 'Data': b'{"col1" : "this is my test json data"}', 'PartitionKey': '1'}]
Utworz recznie Kinesis Firehose dla tego Stream'a dopiero pozniej wygeneruj dane testowe ponizsza petla
for i in range(0,10000):
response = kinesis_client.put_record(
StreamName=STREAM_NAME,
Data=b'{"col1" : "this is json data"}',
PartitionKey='1'
)
[0;31m---------------------------------------------------------------------------[0m [0;31mKeyboardInterrupt[0m Traceback (most recent call last) [0;32m<ipython-input-13-0e9e1b83eba0>[0m in [0;36m<module>[0;34m[0m [1;32m 1[0m [0;32mfor[0m [0mi[0m [0;32min[0m [0mrange[0m[0;34m([0m[0;36m0[0m[0;34m,[0m[0;36m10000[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m----> 2[0;31m response = kinesis_client.put_record( [0m[1;32m 3[0m [0mStreamName[0m[0;34m=[0m[0mSTREAM_NAME[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m [1;32m 4[0m [0mData[0m[0;34m=[0m[0;34mb'{"col1" : "this is json data"}'[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m [1;32m 5[0m [0mPartitionKey[0m[0;34m=[0m[0;34m'1'[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/client.py[0m in [0;36m_api_call[0;34m(self, *args, **kwargs)[0m [1;32m 314[0m "%s() only accepts keyword arguments." % py_operation_name) [1;32m 315[0m [0;31m# The "self" in this scope is referring to the BaseClient.[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 316[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_make_api_call[0m[0;34m([0m[0moperation_name[0m[0;34m,[0m [0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 317[0m [0;34m[0m[0m [1;32m 318[0m [0m_api_call[0m[0;34m.[0m[0m__name__[0m [0;34m=[0m [0mstr[0m[0;34m([0m[0mpy_operation_name[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/client.py[0m in [0;36m_make_api_call[0;34m(self, operation_name, api_params)[0m [1;32m 619[0m [0mhttp[0m[0;34m,[0m [0mparsed_response[0m [0;34m=[0m [0mevent_response[0m[0;34m[0m[0;34m[0m[0m [1;32m 620[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 621[0;31m http, parsed_response = self._make_request( [0m[1;32m 622[0m operation_model, request_dict, request_context) [1;32m 623[0m [0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/client.py[0m in [0;36m_make_request[0;34m(self, operation_model, request_dict, request_context)[0m [1;32m 639[0m [0;32mdef[0m [0m_make_request[0m[0;34m([0m[0mself[0m[0;34m,[0m [0moperation_model[0m[0;34m,[0m [0mrequest_dict[0m[0;34m,[0m [0mrequest_context[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 640[0m [0;32mtry[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 641[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_endpoint[0m[0;34m.[0m[0mmake_request[0m[0;34m([0m[0moperation_model[0m[0;34m,[0m [0mrequest_dict[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 642[0m [0;32mexcept[0m [0mException[0m [0;32mas[0m [0me[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 643[0m self.meta.events.emit( [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/endpoint.py[0m in [0;36mmake_request[0;34m(self, operation_model, request_dict)[0m [1;32m 100[0m logger.debug("Making request for %s with params: %s", [1;32m 101[0m operation_model, request_dict) [0;32m--> 102[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_send_request[0m[0;34m([0m[0mrequest_dict[0m[0;34m,[0m [0moperation_model[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 103[0m [0;34m[0m[0m [1;32m 104[0m [0;32mdef[0m [0mcreate_request[0m[0;34m([0m[0mself[0m[0;34m,[0m [0mparams[0m[0;34m,[0m [0moperation_model[0m[0;34m=[0m[0;32mNone[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/endpoint.py[0m in [0;36m_send_request[0;34m(self, request_dict, operation_model)[0m [1;32m 132[0m [0mrequest[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0mcreate_request[0m[0;34m([0m[0mrequest_dict[0m[0;34m,[0m [0moperation_model[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [1;32m 133[0m [0mcontext[0m [0;34m=[0m [0mrequest_dict[0m[0;34m[[0m[0;34m'context'[0m[0;34m][0m[0;34m[0m[0;34m[0m[0m [0;32m--> 134[0;31m success_response, exception = self._get_response( [0m[1;32m 135[0m request, operation_model, context) [1;32m 136[0m while self._needs_retry(attempts, operation_model, request_dict, [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/endpoint.py[0m in [0;36m_get_response[0;34m(self, request, operation_model, context)[0m [1;32m 164[0m [0;31m# If an exception occurs then the success_response is None.[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [1;32m 165[0m [0;31m# If no exception occurs then exception is None.[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 166[0;31m success_response, exception = self._do_get_response( [0m[1;32m 167[0m request, operation_model) [1;32m 168[0m kwargs_to_emit = { [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/endpoint.py[0m in [0;36m_do_get_response[0;34m(self, request, operation_model)[0m [1;32m 198[0m [0mhttp_response[0m [0;34m=[0m [0mfirst_non_none_response[0m[0;34m([0m[0mresponses[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [1;32m 199[0m [0;32mif[0m [0mhttp_response[0m [0;32mis[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 200[0;31m [0mhttp_response[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0m_send[0m[0;34m([0m[0mrequest[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 201[0m [0;32mexcept[0m [0mHTTPClientError[0m [0;32mas[0m [0me[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 202[0m [0;32mreturn[0m [0;34m([0m[0;32mNone[0m[0;34m,[0m [0me[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/endpoint.py[0m in [0;36m_send[0;34m(self, request)[0m [1;32m 267[0m [0;34m[0m[0m [1;32m 268[0m [0;32mdef[0m [0m_send[0m[0;34m([0m[0mself[0m[0;34m,[0m [0mrequest[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 269[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mhttp_session[0m[0;34m.[0m[0msend[0m[0;34m([0m[0mrequest[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 270[0m [0;34m[0m[0m [1;32m 271[0m [0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/botocore/httpsession.py[0m in [0;36msend[0;34m(self, request)[0m [1;32m 252[0m [0;34m[0m[0m [1;32m 253[0m [0mrequest_target[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0m_get_request_target[0m[0;34m([0m[0mrequest[0m[0;34m.[0m[0murl[0m[0;34m,[0m [0mproxy_url[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 254[0;31m urllib_response = conn.urlopen( [0m[1;32m 255[0m [0mmethod[0m[0;34m=[0m[0mrequest[0m[0;34m.[0m[0mmethod[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m [1;32m 256[0m [0murl[0m[0;34m=[0m[0mrequest_target[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/urllib3/connectionpool.py[0m in [0;36murlopen[0;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)[0m [1;32m 668[0m [0;34m[0m[0m [1;32m 669[0m [0;31m# Make the request on the httplib connection object.[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 670[0;31m httplib_response = self._make_request( [0m[1;32m 671[0m [0mconn[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m [1;32m 672[0m [0mmethod[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/urllib3/connectionpool.py[0m in [0;36m_make_request[0;34m(self, conn, method, url, timeout, chunked, **httplib_request_kw)[0m [1;32m 424[0m [0;31m# Python 3 (including for exceptions like SystemExit).[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [1;32m 425[0m [0;31m# Otherwise it looks like a bug in the code.[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 426[0;31m [0msix[0m[0;34m.[0m[0mraise_from[0m[0;34m([0m[0me[0m[0;34m,[0m [0;32mNone[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 427[0m [0;32mexcept[0m [0;34m([0m[0mSocketTimeout[0m[0;34m,[0m [0mBaseSSLError[0m[0;34m,[0m [0mSocketError[0m[0;34m)[0m [0;32mas[0m [0me[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 428[0m [0mself[0m[0;34m.[0m[0m_raise_timeout[0m[0;34m([0m[0merr[0m[0;34m=[0m[0me[0m[0;34m,[0m [0murl[0m[0;34m=[0m[0murl[0m[0;34m,[0m [0mtimeout_value[0m[0;34m=[0m[0mread_timeout[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/urllib3/packages/six.py[0m in [0;36mraise_from[0;34m(value, from_value)[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/site-packages/urllib3/connectionpool.py[0m in [0;36m_make_request[0;34m(self, conn, method, url, timeout, chunked, **httplib_request_kw)[0m [1;32m 419[0m [0;31m# Python 3[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [1;32m 420[0m [0;32mtry[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 421[0;31m [0mhttplib_response[0m [0;34m=[0m [0mconn[0m[0;34m.[0m[0mgetresponse[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 422[0m [0;32mexcept[0m [0mBaseException[0m [0;32mas[0m [0me[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 423[0m [0;31m# Remove the TypeError from the exception chain in[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/http/client.py[0m in [0;36mgetresponse[0;34m(self)[0m [1;32m 1330[0m [0;32mtry[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 1331[0m [0;32mtry[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m-> 1332[0;31m [0mresponse[0m[0;34m.[0m[0mbegin[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 1333[0m [0;32mexcept[0m [0mConnectionError[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 1334[0m [0mself[0m[0;34m.[0m[0mclose[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/http/client.py[0m in [0;36mbegin[0;34m(self)[0m [1;32m 301[0m [0;31m# read until we get a non-100 response[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [1;32m 302[0m [0;32mwhile[0m [0;32mTrue[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 303[0;31m [0mversion[0m[0;34m,[0m [0mstatus[0m[0;34m,[0m [0mreason[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0m_read_status[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 304[0m [0;32mif[0m [0mstatus[0m [0;34m!=[0m [0mCONTINUE[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 305[0m [0;32mbreak[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/http/client.py[0m in [0;36m_read_status[0;34m(self)[0m [1;32m 262[0m [0;34m[0m[0m [1;32m 263[0m [0;32mdef[0m [0m_read_status[0m[0;34m([0m[0mself[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 264[0;31m [0mline[0m [0;34m=[0m [0mstr[0m[0;34m([0m[0mself[0m[0;34m.[0m[0mfp[0m[0;34m.[0m[0mreadline[0m[0;34m([0m[0m_MAXLINE[0m [0;34m+[0m [0;36m1[0m[0;34m)[0m[0;34m,[0m [0;34m"iso-8859-1"[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 265[0m [0;32mif[0m [0mlen[0m[0;34m([0m[0mline[0m[0;34m)[0m [0;34m>[0m [0m_MAXLINE[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 266[0m [0;32mraise[0m [0mLineTooLong[0m[0;34m([0m[0;34m"status line"[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/socket.py[0m in [0;36mreadinto[0;34m(self, b)[0m [1;32m 667[0m [0;32mwhile[0m [0;32mTrue[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 668[0m [0;32mtry[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 669[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_sock[0m[0;34m.[0m[0mrecv_into[0m[0;34m([0m[0mb[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 670[0m [0;32mexcept[0m [0mtimeout[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 671[0m [0mself[0m[0;34m.[0m[0m_timeout_occurred[0m [0;34m=[0m [0;32mTrue[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/ssl.py[0m in [0;36mrecv_into[0;34m(self, buffer, nbytes, flags)[0m [1;32m 1239[0m [0;34m"non-zero flags not allowed in calls to recv_into() on %s"[0m [0;34m%[0m[0;34m[0m[0;34m[0m[0m [1;32m 1240[0m self.__class__) [0;32m-> 1241[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mread[0m[0;34m([0m[0mnbytes[0m[0;34m,[0m [0mbuffer[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 1242[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 1243[0m [0;32mreturn[0m [0msuper[0m[0;34m([0m[0;34m)[0m[0;34m.[0m[0mrecv_into[0m[0;34m([0m[0mbuffer[0m[0;34m,[0m [0mnbytes[0m[0;34m,[0m [0mflags[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m~/opt/anaconda3/envs/uam-d/lib/python3.8/ssl.py[0m in [0;36mread[0;34m(self, len, buffer)[0m [1;32m 1097[0m [0;32mtry[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 1098[0m [0;32mif[0m [0mbuffer[0m [0;32mis[0m [0;32mnot[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m-> 1099[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_sslobj[0m[0;34m.[0m[0mread[0m[0;34m([0m[0mlen[0m[0;34m,[0m [0mbuffer[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 1100[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 1101[0m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_sslobj[0m[0;34m.[0m[0mread[0m[0;34m([0m[0mlen[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;31mKeyboardInterrupt[0m:
BUCKET_NAME = 'datalake-uam'
GLUE_DB = 'uam'
KINESIS_STREAM = 'uam-test'
KINESIS_FIREHOSE = 'uam-test-fh'
s3_client = session.client("s3")
glue_client = session.client("glue")
def tear_down_all():
s3 = boto3.resource('s3',**session_kwargs)
bucket = s3.Bucket(BUCKET_NAME)
bucket.objects.delete()
s3_client.delete_bucket(
Bucket = BUCKET_NAME
)
glue_client.delete_database(
Name=GLUE_DB
)
kinesis_client.delete_stream(StreamName=STREAM_NAME)
tear_down_all()