flow_logs
Creates, updates, deletes, gets or lists a flow_logs resource.
Overview
| Name | flow_logs |
| Type | Resource |
| Id | aws.ec2.flow_logs |
Fields
The following fields are returned by SELECT queries:
- describe_flow_logs
| Name | Datatype | Description |
|---|---|---|
creation_time | string | The date and time the flow log was created. |
deliver_cross_account_role | string | The ARN of the IAM role that allows the service to publish flow logs across accounts. |
deliver_logs_error_message | string | Information 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_arn | string | The ARN of the IAM role allows the service to publish logs to CloudWatch Logs. |
deliver_logs_status | string | The status of the logs delivery (SUCCESS | FAILED). |
destination_options | string | The destination options. |
flow_log_id | string | The ID of the flow log. |
flow_log_status | string | The status of the flow log (ACTIVE). |
log_destination | string | The Amazon Resource Name (ARN) of the destination for the flow log data. |
log_destination_type | string | The type of destination for the flow log data. |
log_format | string | The format of the flow log record. |
log_group_name | string | The name of the flow log group. |
max_aggregation_interval | integer | The 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_id | string | The ID of the resource being monitored. |
tag_field_specifications | string | The tag configuration associated with the Flow Logs Amazon EC2 Tags feature fields in your custom log format. |
tags | string | The tags for the flow log. |
traffic_type | string | The type of traffic captured for the flow log. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_flow_logs | select | region | DryRun, Filter, FlowLogId, MaxResults, NextToken | 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. |
create_flow_logs | insert | ResourceId, ResourceType, region | DryRun, ClientToken, DeliverLogsPermissionArn, DeliverCrossAccountRole, LogGroupName, TrafficType, LogDestinationType, LogDestination, LogFormat, TagSpecification, MaxAggregationInterval, DestinationOptions, TagFieldSpecification | 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. |
delete_flow_logs | delete | FlowLogId, region | DryRun | Deletes 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.
| Name | Datatype | Description |
|---|---|---|
FlowLogId | array | One or more flow log IDs. Constraint: Maximum of 1000 flow log IDs. |
ResourceId | array | The 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. |
ResourceType | string | The type of resource to monitor. |
region | string | AWS region (default: us-east-1) |
ClientToken | string | Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency. |
DeliverCrossAccountRole | string | The ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts. |
DeliverLogsPermissionArn | string | The 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. |
DestinationOptions | object | The destination options. |
DryRun | boolean | Checks 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. |
Filter | array | One 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. |
FlowLogId | array | One or more flow log IDs. Constraint: Maximum of 1000 flow log IDs. |
LogDestination | string | The 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 |
LogDestinationType | string | The type of destination for the flow log data. Default: cloud-watch-logs |
LogFormat | string | The 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. |
LogGroupName | string | The 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. |
MaxAggregationInterval | integer | The 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 |
MaxResults | integer | The 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. |
NextToken | string | The token to request the next page of items. Pagination continues from the end of the items returned by the previous request. |
TagFieldSpecification | array | The tag configuration associated with the Flow Logs Amazon EC2 Tags feature fields in your custom log format. |
TagSpecification | array | The tags to apply to the flow logs. |
TrafficType | string | The 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
- describe_flow_logs
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
- create_flow_logs
- Manifest
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
;
# Description fields are for documentation purposes
- name: flow_logs
props:
- name: ResourceId
value: "{{ ResourceId }}"
description: Required parameter for the flow_logs resource.
- name: ResourceType
value: "{{ ResourceType }}"
description: Required parameter for the flow_logs resource.
- name: region
value: "{{ region }}"
description: Required parameter for the flow_logs resource.
- name: DryRun
value: {{ DryRun }}
description: Checks 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.
description: Checks 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.
- name: ClientToken
value: "{{ ClientToken }}"
description: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.
description: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.
- name: DeliverLogsPermissionArn
value: "{{ DeliverLogsPermissionArn }}"
description: The 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.
description: The 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.
- name: DeliverCrossAccountRole
value: "{{ DeliverCrossAccountRole }}"
description: The ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts.
description: The ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts.
- name: LogGroupName
value: "{{ LogGroupName }}"
description: The 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.
description: The 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.
- name: TrafficType
value: "{{ TrafficType }}"
description: The 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.
description: The 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.
- name: LogDestinationType
value: "{{ LogDestinationType }}"
description: The type of destination for the flow log data. Default: cloud-watch-logs
description: The type of destination for the flow log data. Default: cloud-watch-logs
- name: LogDestination
value: "{{ LogDestination }}"
description: The 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
description: The 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
- name: LogFormat
value: "{{ LogFormat }}"
description: The 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.
description: The 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.
- name: TagSpecification
value: "{{ TagSpecification }}"
description: The tags to apply to the flow logs.
description: The tags to apply to the flow logs.
- name: MaxAggregationInterval
value: {{ MaxAggregationInterval }}
description: The 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
description: The 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
- name: DestinationOptions
value: "{{ DestinationOptions }}"
description: The destination options.
description: The destination options.
- name: TagFieldSpecification
value: "{{ TagFieldSpecification }}"
description: The tag configuration associated with the Flow Logs Amazon EC2 Tags feature fields in your custom log format.
description: The tag configuration associated with the Flow Logs Amazon EC2 Tags feature fields in your custom log format.
DELETE examples
- delete_flow_logs
Deletes one or more flow logs.
DELETE FROM aws.ec2.flow_logs
WHERE FlowLogId = '{{ FlowLogId }}' --required
AND region = '{{ region }}' --required
AND DryRun = '{{ DryRun }}'
;