Write code that downloads all of the log files ending in `.log` in an S3 bucket and
Question:
Write code that downloads all of the log files ending in `.log` in an S3 bucket and counts the total number of HTTP errors in those logs.
Log lines are in the format `{"path": "/", status: 200}` or `{"path": "/", status: 404}`, for example. (This is JSON, and you can process it as such if you choose.)
Use the bucket `class6-logs`, the access key ID "AKIASUMBPHIPY6DLZ4C5", and the secret access key "JQdQIbxsRcipnoKFnsfse44SMRGouzz4tbAzTYbe".
Use the code below to get started:
Code-
import boto3
client = boto3.client(
's3',
aws_access_key_id="AKIASUMBPHIPY6DLZ4C5",
aws_secret_access_key="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",
)
resp = client.list_objects(Bucket='class6-logs')
client.download_file('class6-logs', resp['Contents'][0]
['Key'], 'downloaded_file')
# for object in resp['Contents']:
# print(object['Key'])
# print(resp['Contents'][0]['Key'])
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill