Skip to content

EC2  >  Operations  >  create_flow_logs

create_flow_logs

Operation

create_flow_logs async

create_flow_logs(input: CreateFlowLogsInput, plugins: list[Plugin] | None = None) -> CreateFlowLogsOutput

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.

Parameters:

Name Type Description Default
input CreateFlowLogsInput

An instance of CreateFlowLogsInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
CreateFlowLogsOutput

An instance of CreateFlowLogsOutput.

Input

CreateFlowLogsInput dataclass

Bases: _SerdeShape

Dataclass for CreateFlowLogsInput structure.

Attributes

client_token class-attribute instance-attribute
client_token: str | None = ...

Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.

deliver_cross_account_role class-attribute instance-attribute
deliver_cross_account_role: str | None = ...

The ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts.

deliver_logs_permission_arn class-attribute instance-attribute
deliver_logs_permission_arn: str | None = ...

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.

destination_options class-attribute instance-attribute
destination_options: DestinationOptionsRequest | None = ...

The destination options.

dry_run class-attribute instance-attribute
dry_run: bool | None = ...

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.

log_destination class-attribute instance-attribute
log_destination: str | None = ...

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

log_destination_type class-attribute instance-attribute
log_destination_type: str | None = ...

The type of destination for the flow log data.

Default: cloud-watch-logs

log_format class-attribute instance-attribute
log_format: str | None = ...

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, Transit Gateway Flow Log records in the Amazon Web Services Transit Gateway Guide, or Cloud WAN Flow Log records in the Amazon Web Services Cloud WAN User Guide.

Specify the fields using the ${field-id} format, separated by spaces.

log_group_name class-attribute instance-attribute
log_group_name: str | None = ...

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.

max_aggregation_interval class-attribute instance-attribute
max_aggregation_interval: int | None = ...

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 and Cloud WAN 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

resource_ids class-attribute instance-attribute
resource_ids: list[str] | None = ...

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.

resource_type class-attribute instance-attribute
resource_type: str | None = ...

The type of resource to monitor.

tag_field_specifications class-attribute instance-attribute
tag_field_specifications: list[TagFieldSpecificationRequest] | None = ...

The tag configuration associated with the Flow Logs Amazon EC2 Tags feature fields in your custom log format.

tag_specifications class-attribute instance-attribute
tag_specifications: list[TagSpecification] | None = ...

The tags to apply to the flow logs.

traffic_type class-attribute instance-attribute
traffic_type: str | None = ...

The type of traffic to monitor (accepted traffic, rejected traffic, or all traffic). This parameter is not supported for transit gateway or Cloud WAN resource types. It is required for the other resource types.

Output

CreateFlowLogsOutput dataclass

Bases: _SerdeShape

Dataclass for CreateFlowLogsOutput structure.

Attributes

client_token class-attribute instance-attribute
client_token: str | None = ...

Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

flow_log_ids class-attribute instance-attribute
flow_log_ids: list[str] | None = ...

The IDs of the flow logs.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

unsuccessful class-attribute instance-attribute
unsuccessful: list[UnsuccessfulItem] | None = ...

Information about the flow logs that could not be created successfully.