aws-cdk-lib.aws_ec2.FlowLogProps

interface FlowLogProps

LanguageType name
.NETAmazon.CDK.AWS.EC2.FlowLogProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#FlowLogProps
Javasoftware.amazon.awscdk.services.ec2.FlowLogProps
Pythonaws_cdk.aws_ec2.FlowLogProps
TypeScript (source)aws-cdk-lib » aws_ec2 » FlowLogProps

Properties of a VPC Flow Log.

Example

declare const vpc: ec2.Vpc;

const logGroup = new logs.LogGroup(this, 'MyCustomLogGroup');

const role = new iam.Role(this, 'MyCustomRole', {
  assumedBy: new iam.ServicePrincipal('vpc-flow-logs.amazonaws.com')
});

new ec2.FlowLog(this, 'FlowLog', {
  resourceType: ec2.FlowLogResourceType.fromVpc(vpc),
  destination: ec2.FlowLogDestination.toCloudWatchLogs(logGroup, role)
});

Properties

NameTypeDescription
resourceTypeFlowLogResourceTypeThe type of resource for which to create the flow log.
destination?FlowLogDestinationSpecifies the type of destination to which the flow log data is to be published.
flowLogName?stringThe name of the FlowLog.
logFormat?LogFormat[]The fields to include in the flow log record, in the order in which they should appear.
maxAggregationInterval?FlowLogMaxAggregationIntervalThe maximum interval of time during which a flow of packets is captured and aggregated into a flow log record.
trafficType?FlowLogTrafficTypeThe type of traffic to log.

resourceType

Type: FlowLogResourceType

The type of resource for which to create the flow log.


destination?

Type: FlowLogDestination (optional, default: FlowLogDestinationType.toCloudWatchLogs())

Specifies the type of destination to which the flow log data is to be published.

Flow log data can be published to CloudWatch Logs or Amazon S3


flowLogName?

Type: string (optional, default: If you don't specify a flowLogName, AWS CloudFormation generates a unique physical ID and uses that ID for the group name.)

The name of the FlowLog.

It is not recommended to use an explicit name.


logFormat?

Type: LogFormat[] (optional, default: default log format is used.)

The fields to include in the flow log record, in the order in which they should appear.

If multiple fields are specified, they will be separated by spaces. For full control over the literal log format string, pass a single field constructed with LogFormat.custom().

See https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-log-records


maxAggregationInterval?

Type: FlowLogMaxAggregationInterval (optional, default: FlowLogMaxAggregationInterval.TEN_MINUTES)

The maximum interval of time during which a flow of packets is captured and aggregated into a flow log record.


trafficType?

Type: FlowLogTrafficType (optional, default: ALL)

The type of traffic to log.

You can log traffic that the resource accepts or rejects, or all traffic.