Я новичок в API AWS SDK.
У меня есть ведро s3 (my-bucket), которое мой клиент использует для загрузки файлов оттуда. У меня есть Trail (my-trail), используемый для доставки журналов в другое ведро s3 (my-bucket-logs) всякий раз, когда мой клиент загружает файлы из «my-bucket».
Я хочу читать журналы из «my-bucket-logs» и сохранять их в своей CMS для создания различных отчетов. Можно ли получить логи? Я пробовал ниже PHP-код. Я не уверен, правильный ли этот код или нет.
require 'vendor/autoload.php';
$config = [
'version' => 'latest',
'region' => 'us-east-1',
'key' => MY_AWS_KEY,
'secret' => MY_AWS_SECRETE
];
$s3client = new Aws\S3\S3Client($config);
$trailClient = new Aws\CloudTrail\CloudTrailClient($config);
$result = $trailClient->lookupEvents([
'EndTime' => time(),
'LookupAttributes' => [
[
'AttributeKey' => 'eventName',// 'get', // REQUIRED
'AttributeValue' => 'ListObjects' //get', // REQUIRED
],
// ...
],
'MaxResults' => 1000
//'NextToken' => '<string>',
//'StartTime' => '01/12/2017',
]);
print_r($result);
Получение этой ошибки:
PHP Fatal error: Uncaught exception 'Aws\CloudTrail\Exception\CloudTrailException' with message 'Error executing "LookupEvents" on "https://cloudtrail.us-east-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://cloudtrail.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response:
{"__type":"InvalidLookupAttributesException","Message":"You cannot perform a lookup on this attribute key: EventId|Event (truncated...)
InvalidLookupAttributesException (client): You cannot perform a lookup on this attribute key: EventId|EventName|Username|ResourceType|ResourceName|EventSource - {"__type":"InvalidLookupAttributesException","Message":"You cannot perform a lookup on this attribute key: EventId|EventName|Username|ResourceType|ResourceName|EventSource"}'
exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: `POST https://cloudtrail.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response:
{"__type":"InvalidLookupAttributesException","Message":"You cannot perform a lookup on this attribu in /home/shahid/webroot/shahid/aws/sdk/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 191
Можно ли получать журналы с помощью AWS SDK API в PHP?