src/CloudTrail/LogFileReader.php
public function read($s3BucketName, $logFileKey)
    {
        // Create a command for getting the log file object
        $command = $this->s3Client->getCommand('GetObject', [
            'Bucket' => (string) $s3BucketName,
            'Key' => (string) $logFileKey,
            'ResponseContentEncoding' => 'x-gzip'
        ]);

        // Make sure gzip encoding header is sent and accepted in order to
        // inflate the response data.
        $command['@http']['headers']['Accept-Encoding'] = 'gzip';

        // Get the JSON response data and extract the log records
        $result = $this->s3Client->execute($command);
        $logData = json_decode($result['Body'], true);

        return isset($logData['Records']) ? $logData['Records'] : [];
    }
public function read($s3BucketName, $logFileKey)
    {
        // Create a command for getting the log file object
        $command = $this->s3Client->getCommand('GetObject', [
            'Bucket' => (string) $s3BucketName,
            'Key' => (string) $logFileKey,
            'ResponseContentEncoding' => 'x-gzip'
        ]);

        // Make sure gzip encoding header is sent and accepted in order to
        // inflate the response data.
        $command['@http']['headers']['Accept-Encoding'] = 'gzip';

        // Get the JSON response data and extract the log records
        $result = $this->s3Client->execute($command);
        $logData = json_decode($result['Body'], true);

        return isset($logData['Records']) ? $logData['Records'] : [];
    }
public function read ( $ s3BucketName , $ logFileKey ) { // Create a command for getting the log file object $ command = $ this -> s3Client -> getCommand ( 'GetObject' , [ 'Bucket' => ( string ) $ s3BucketName , 'Key' => ( string ) $ logFileKey , 'ResponseContentEncoding' => 'x-gzip' ] ) ; // Make sure gzip encoding header is sent and accepted in order to // inflate the response data. $ command [ '@http' ] [ 'headers' ] [ 'Accept-Encoding' ] = 'gzip' ; // Get the JSON response data and extract the log records $ result = $ this -> s3Client -> execute ( $ command ) ; $ logData = json_decode ( $ result [ 'Body' ] , true ) ; return isset ( $ logData [ 'Records' ] ) ? $ logData [ 'Records' ] : [ ] ; }
Downloads, unzips, and reads a CloudTrail log file from Amazon S3

@param string $s3BucketName The bucket name of the log file in Amazon S3
@param string $logFileKey   The key of the log file in Amazon S3

@return array
Downloads unzips and reads a CloudTrail log file from Amazon S3