Class LogFileIterator
- IteratorIterator implements Iterator, Traversable, OuterIterator
-
Aws\CloudTrail\LogFileIterator
- Namespace: Aws\CloudTrail
- Located at CloudTrail/LogFileIterator.php
The Aws\CloudTrail\LogFileIterator
provides an easy way to iterate over
log file generated by AWS CloudTrail.
CloudTrail log files contain data about your AWS API calls and are stored in Amazon S3 at a predictable path based on a bucket name, a key prefix, an account ID, a region, and date information. This class allows you to specify options, including a date range, and emits each log file that match the provided options.
Yields an array containing the Amazon S3 bucket and key of the log file.
Methods Summary
-
static
forTrail ( Aws\S3\S3Client $s3Client, Aws\CloudTrail\CloudTrailClient $cloudTrailClient, array $options = [] )
Constructs a LogRecordIterator. This factory method is used if the name of the S3 bucket containing your logs is not known. This factory method uses a CloudTrail client and the trail name (or "Default") to find the information about the trail necessary for constructing the LogRecordIterator.
-
__construct ( Aws\S3\S3Client $s3Client, string $s3BucketName, array $options = [] )
Constructs a LogFileIterator using the specified options:
- current ( )
Methods inherited from IteratorIterator
getInnerIterator()
,
key()
,
next()
,
rewind()
,
valid()
Methods Details
static
Aws\CloudTrail\LogRecordIterator
forTrail (
Aws\S3\S3Client
$s3Client,
Aws\CloudTrail\CloudTrailClient
$cloudTrailClient,
array
$options = []
)
Constructs a LogRecordIterator. This factory method is used if the name of the S3 bucket containing your logs is not known. This factory method uses a CloudTrail client and the trail name (or "Default") to find the information about the trail necessary for constructing the LogRecordIterator.
Parameters
Aws\S3\S3Client |
$s3Client | |
Aws\CloudTrail\CloudTrailClient |
$cloudTrailClient | |
array | $options = [] |
Returns
Aws\CloudTrail\LogRecordIterator |
Exceptions
InvalidArgumentException |
See
__construct (
Aws\S3\S3Client
$s3Client,
string
$s3BucketName,
array
$options = []
)
Constructs a LogFileIterator using the specified options:
- trail_name: The name of the trail that is generating our logs. If none is provided, then "Default" will be used, since that is the name of the trail created in the AWS Management Console.
- key_prefix: The S3 key prefix of your log files. This value will be overwritten when using the
fromTrail()
method. However, if you are using the constructor, then this value will be used. - start_date: The timestamp of the beginning of date range of the log records you want to read. You can pass this in as a
DateTime
object, integer (unix timestamp), or a string compatible withstrtotime()
. - end_date: The timestamp of the end of date range of the log records you want to read. You can pass this in as a
DateTime
object, integer (unix timestamp), or a string compatible withstrtotime()
. - account_id: This is your AWS account ID, which is the 12-digit number found on the Account Identifiers section of the AWS Security Credentials page. See https://console.aws.amazon.com/iam/home?#security_credential
- log_region: Region of the services of the log records you want to read.
Parameters
Aws\S3\S3Client |
$s3Client | |
string | $s3BucketName | |
array | $options = [] |
Overrides
IteratorIterator::__construct
current ( )
Overrides
IteratorIterator::current
Constants summary
string |
DEFAULT_TRAIL_NAME
|
#
'Default'
|
string |
PREFIX_TEMPLATE
|
#
'prefix/AWSLogs/account/CloudTrail/region/date/'
|
string |
PREFIX_WILDCARD
|
#
'*'
|
string |
TRAIL_NAME
|
#
'trail_name'
|
string |
KEY_PREFIX
|
#
'key_prefix'
|
string |
START_DATE
|
#
'start_date'
|
string |
END_DATE
|
#
'end_date'
|
string |
ACCOUNT_ID
|
#
'account_id'
|
string |
LOG_REGION
|
#
'log_region'
|