Skip to main content

flow_logs

Creates, updates, deletes, gets or lists a flow_logs resource.

Overview

Nameflow_logs
TypeResource
Idaws.ec2.flow_logs

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
creation_timestringThe date and time the flow log was created.
deliver_cross_account_rolestringThe ARN of the IAM role that allows the service to publish flow logs across accounts.
deliver_logs_error_messagestringInformation about the error that occurred. Rate limited indicates that CloudWatch Logs throttling has been applied for one or more network interfaces, or that you've reached the limit on the number of log groups that you can create. Access error indicates that the IAM role associated with the flow log does not have sufficient permissions to publish to CloudWatch Logs. Unknown error indicates an internal error.
deliver_logs_permission_arnstringThe ARN of the IAM role allows the service to publish logs to CloudWatch Logs.
deliver_logs_statusstringThe status of the logs delivery (SUCCESS | FAILED).
destination_optionsstringThe destination options.
flow_log_idstringThe ID of the flow log.
flow_log_statusstringThe status of the flow log (ACTIVE).
log_destinationstringThe Amazon Resource Name (ARN) of the destination for the flow log data.
log_destination_typestringThe type of destination for the flow log data.
log_formatstringThe format of the flow log record.
log_group_namestringThe name of the flow log group.
max_aggregation_intervalintegerThe maximum interval of time, in seconds, during which a flow of packets is captured and aggregated into a flow log record. When a network interface is attached to a Nitro-based instance, the aggregation interval is always 60 seconds (1 minute) or less, regardless of the specified value. Valid Values: 60 | 600
resource_idstringThe ID of the resource being monitored.
tag_field_specificationsstringThe tag configuration associated with the Flow Logs Amazon EC2 Tags feature fields in your custom log format.
tagsstringThe tags for the flow log.
traffic_typestringThe type of traffic captured for the flow log.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_flow_logsselectregionDryRun, Filter, FlowLogId, MaxResults, NextTokenDescribes one or more flow logs. To view the published flow log records, you must view the log destination. For example, the CloudWatch Logs log group, the Amazon S3 bucket, or the Kinesis Data Firehose delivery stream.
create_flow_logsinsertResourceId, ResourceType, regionDryRun, ClientToken, DeliverLogsPermissionArn, DeliverCrossAccountRole, LogGroupName, TrafficType, LogDestinationType, LogDestination, LogFormat, TagSpecification, MaxAggregationInterval, DestinationOptions, TagFieldSpecificationCreates one or more flow logs to capture information about IP traffic for a specific network interface, subnet, or VPC. Flow log data for a monitored network interface is recorded as flow log records, which are log events consisting of fields that describe the traffic flow. For more information, see Flow log records in the Amazon VPC User Guide. When publishing to CloudWatch Logs, flow log records are published to a log group, and each network interface has a unique log stream in the log group. When publishing to Amazon S3, flow log records for all of the monitored network interfaces are published to a single log file object that is stored in the specified bucket. For more information, see VPC Flow Logs in the Amazon VPC User Guide.
delete_flow_logsdeleteFlowLogId, regionDryRunDeletes one or more flow logs.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
FlowLogIdarrayOne or more flow log IDs. Constraint: Maximum of 1000 flow log IDs.
ResourceIdarrayThe IDs of the resources to monitor. For example, if the resource type is VPC, specify the IDs of the VPCs. Constraints: Maximum of 25 for transit gateway resource types. Maximum of 300 for the other resource types.
ResourceTypestringThe type of resource to monitor.
regionstringAWS region (default: us-east-1)
ClientTokenstringUnique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.
DeliverCrossAccountRolestringThe ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts.
DeliverLogsPermissionArnstringThe ARN of the IAM role that allows Amazon EC2 to publish flow logs to the log destination. This parameter is required if the destination type is cloud-watch-logs, or if the destination type is kinesis-data-firehose and the delivery stream and the resources to monitor are in different accounts.
DestinationOptionsobjectThe destination options.
DryRunbooleanChecks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
FilterarrayOne or more filters. deliver-log-status - The status of the logs delivery (SUCCESS | FAILED). log-destination-type - The type of destination for the flow log data (cloud-watch-logs | s3 | kinesis-data-firehose). flow-log-id - The ID of the flow log. log-group-name - The name of the log group. resource-id - The ID of the VPC, subnet, or network interface. traffic-type - The type of traffic (ACCEPT | REJECT | ALL). tag:<key> - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value. tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.
FlowLogIdarrayOne or more flow log IDs. Constraint: Maximum of 1000 flow log IDs.
LogDestinationstringThe destination for the flow log data. The meaning of this parameter depends on the destination type. If the destination type is cloud-watch-logs, specify the ARN of a CloudWatch Logs log group. For example: arn:aws:logs:region:account_id:log-group:my_group Alternatively, use the LogGroupName parameter. If the destination type is s3, specify the ARN of an S3 bucket. For example: arn:aws:s3:::my_bucket/my_subfolder/ The subfolder is optional. Note that you can't use AWSLogs as a subfolder name. If the destination type is kinesis-data-firehose, specify the ARN of a Kinesis Data Firehose delivery stream. For example: arn:aws:firehose:region:account_id:deliverystream:my_stream
LogDestinationTypestringThe type of destination for the flow log data. Default: cloud-watch-logs
LogFormatstringThe fields to include in the flow log record. List the fields in the order in which they should appear. If you omit this parameter, the flow log is created using the default format. If you specify this parameter, you must include at least one field. For more information about the available fields, see Flow log records in the Amazon VPC User Guide or Transit Gateway Flow Log records in the Amazon Web Services Transit Gateway Guide. Specify the fields using the ${field-id} format, separated by spaces.
LogGroupNamestringThe name of a new or existing CloudWatch Logs log group where Amazon EC2 publishes your flow logs. This parameter is valid only if the destination type is cloud-watch-logs.
MaxAggregationIntervalintegerThe maximum interval of time during which a flow of packets is captured and aggregated into a flow log record. The possible values are 60 seconds (1 minute) or 600 seconds (10 minutes). This parameter must be 60 seconds for transit gateway resource types. When a network interface is attached to a Nitro-based instance, the aggregation interval is always 60 seconds or less, regardless of the value that you specify. Default: 600
MaxResultsintegerThe maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.
NextTokenstringThe token to request the next page of items. Pagination continues from the end of the items returned by the previous request.
TagFieldSpecificationarrayThe tag configuration associated with the Flow Logs Amazon EC2 Tags feature fields in your custom log format.
TagSpecificationarrayThe tags to apply to the flow logs.
TrafficTypestringThe type of traffic to monitor (accepted traffic, rejected traffic, or all traffic). This parameter is not supported for transit gateway resource types. It is required for the other resource types.

SELECT examples

Describes one or more flow logs. To view the published flow log records, you must view the log destination. For example, the CloudWatch Logs log group, the Amazon S3 bucket, or the Kinesis Data Firehose delivery stream.

SELECT
creation_time,
deliver_cross_account_role,
deliver_logs_error_message,
deliver_logs_permission_arn,
deliver_logs_status,
destination_options,
flow_log_id,
flow_log_status,
log_destination,
log_destination_type,
log_format,
log_group_name,
max_aggregation_interval,
resource_id,
tag_field_specifications,
tags,
traffic_type
FROM aws.ec2.flow_logs
WHERE region = '{{ region }}' -- required
AND DryRun = '{{ DryRun }}'
AND Filter = '{{ Filter }}'
AND FlowLogId = '{{ FlowLogId }}'
AND MaxResults = '{{ MaxResults }}'
AND NextToken = '{{ NextToken }}'
;

INSERT examples

Creates one or more flow logs to capture information about IP traffic for a specific network interface, subnet, or VPC. Flow log data for a monitored network interface is recorded as flow log records, which are log events consisting of fields that describe the traffic flow. For more information, see Flow log records in the Amazon VPC User Guide. When publishing to CloudWatch Logs, flow log records are published to a log group, and each network interface has a unique log stream in the log group. When publishing to Amazon S3, flow log records for all of the monitored network interfaces are published to a single log file object that is stored in the specified bucket. For more information, see VPC Flow Logs in the Amazon VPC User Guide.

INSERT INTO aws.ec2.flow_logs (
ResourceId,
ResourceType,
region,
DryRun,
ClientToken,
DeliverLogsPermissionArn,
DeliverCrossAccountRole,
LogGroupName,
TrafficType,
LogDestinationType,
LogDestination,
LogFormat,
TagSpecification,
MaxAggregationInterval,
DestinationOptions,
TagFieldSpecification
)
SELECT
'{{ ResourceId }}',
'{{ ResourceType }}',
'{{ region }}',
'{{ DryRun }}',
'{{ ClientToken }}',
'{{ DeliverLogsPermissionArn }}',
'{{ DeliverCrossAccountRole }}',
'{{ LogGroupName }}',
'{{ TrafficType }}',
'{{ LogDestinationType }}',
'{{ LogDestination }}',
'{{ LogFormat }}',
'{{ TagSpecification }}',
'{{ MaxAggregationInterval }}',
'{{ DestinationOptions }}',
'{{ TagFieldSpecification }}'
RETURNING
client_token,
flow_log_ids,
unsuccessful
;

DELETE examples

Deletes one or more flow logs.

DELETE FROM aws.ec2.flow_logs
WHERE FlowLogId = '{{ FlowLogId }}' --required
AND region = '{{ region }}' --required
AND DryRun = '{{ DryRun }}'
;