def read_s3_content()

in src/lakeformation_automation/lambda_function.py [0:0]


def read_s3_content(bucket, key):
    """ Reads the contents of s3 object
        Arguments:
            bucket {str} -- Name of the bucket
            key {str} -- object key
        Returns:
            contents of s3 object
    """
    try:
        s3 = boto3.resource('s3')
        obj = s3.Object(bucket, key)
        s3_content = obj.get()['Body'].read().decode('utf-8')
        s3_content = json.loads(obj.get()['Body'].read().decode('utf-8'))
        return s3_content
    except Exception as e:
        logger.error('Exception while reading data from s3::/{}/{}'.format(bucket, key))
        raise e