Set-Up AWS FlowLogs to S3
Set-Up AWS Flow Logs to be sent to an S3 Bucket
This section will describe how to configure VPC flow logs that are to be sent to a S3 bucket.
AWS Flow Logs
VPC Flow Logs collects flow log records, consolidates them into log files, and then publishes the log files to the Amazon S3 bucket at 5-minute intervals. Each log file contains flow log records for the IP traffic recorded in the previous five minutes.
The maximum file size for a log file is 75 MB. If the log file reaches the file size limit within the 5-minute period, the flow log stops adding flow log records to it. Then it publishes the flow log to the Amazon S3 bucket, and creates a new log file.
In Amazon S3, the Last modified field for the flow log file indicates the date and time at which the file was uploaded to the Amazon S3 bucket. This is later than the timestamp in the file name, and differs by the amount of time taken to upload the file to the Amazon S3 bucket.
IAM Policy to publish logs to an S3 bucket
In order to publish the flow logs, the IAM pricipal such as a User, needs to have the following policy:
Bucket permissions
When creating a bucket in S3, the content of the bucket is private and only accessible to the user that created it. Since the bucket content needs to be read by the agent, a policy needs to be added to that user in order to make the content available.
The following must be filled by you:
my-s3-arn
, the ARN of the S3 bucket where the logs are storedaccount_id
, the account idregion
, a specific region or*
bucket_name
, the name of the bucket where the logs are stored.
Add a VPC Flow Log
- Open the Amazon VPC console at https://console.aws.amazon.com/vpc/
- In the navigation pane, choose Your VPCs.
- Select the checkboxes for one or more VPCs.
- Choose Actions, Create flow log.
- Configure the flow log settings. For more information, see below.
To configure flow log settings using the console
- For Filter, specify the type of IP traffic data to log. Here please select
All
-
For Maximum aggregation interval, choose the maximum period of time during which a flow is captured and aggregated into one flow log record.
-
For Destination, choose Send to an S3 bucket.
-
For S3 bucket ARN, specify the Amazon Resource Name (ARN) of an existing Amazon S3 bucket. You can optionally include a subfolder. For example, to specify a subfolder named my-logs in a bucket named my-bucket, use the following ARN:
The bucket cannot use AWSLogs as a subfolder name, as this is a reserved term.
If you own the bucket, we automatically create a resource policy and attach it to the bucket. For more information, see Amazon S3 bucket permissions for flow logs.
For Log record format, specify the format for the flow log record. Here please select
Custom
and proceed to select all fields. -
For Log file format, specify the format for the log file.
-
(Optional) To use Hive-compatible S3 prefixes, choose Hive-compatible S3 prefix, Enable.
-
To partition your flow logs per hour, choose Every 1 hour (60 mins).
-
(Optional) To add a tag to the flow log, choose Add new tag and specify the tag key and value.
-
Choose Create flow log.