FlowLogOptions Struct
Options to add a flow log to a VPC.
Example
const vpc = new ec2.Vpc(this, 'Vpc');
vpc.addFlowLog('FlowLogS3', {
destination: ec2.FlowLogDestination.toS3()
});
// Only reject traffic and interval every minute.
vpc.addFlowLog('FlowLogCloudWatch', {
trafficType: ec2.FlowLogTrafficType.REJECT,
maxAggregationInterval: ec2.FlowLogMaxAggregationInterval.ONE_MINUTE,
});
vpc = ec2.Vpc(self, "Vpc")
vpc.add_flow_log("FlowLogS3",
destination=ec2.FlowLogDestination.to_s3()
)
# Only reject traffic and interval every minute.
vpc.add_flow_log("FlowLogCloudWatch",
traffic_type=ec2.FlowLogTrafficType.REJECT,
max_aggregation_interval=ec2.FlowLogMaxAggregationInterval.ONE_MINUTE
)
Vpc vpc = new Vpc(this, "Vpc");
vpc.addFlowLog("FlowLogS3", FlowLogOptions.builder()
.destination(FlowLogDestination.toS3())
.build());
// Only reject traffic and interval every minute.
vpc.addFlowLog("FlowLogCloudWatch", FlowLogOptions.builder()
.trafficType(FlowLogTrafficType.REJECT)
.maxAggregationInterval(FlowLogMaxAggregationInterval.ONE_MINUTE)
.build());
// Install: dotnet add package Amazon.CDK.Lib
var vpc = new Vpc(this, "Vpc");
vpc.AddFlowLog("FlowLogS3", new FlowLogOptions {
Destination = FlowLogDestination.ToS3()
});
// Only reject traffic and interval every minute.
vpc.AddFlowLog("FlowLogCloudWatch", new FlowLogOptions {
TrafficType = FlowLogTrafficType.REJECT,
MaxAggregationInterval = FlowLogMaxAggregationInterval.ONE_MINUTE
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
vpc := ec2.NewVpc(this, jsii.String("Vpc"))
vpc.addFlowLog(jsii.String("FlowLogS3"), &FlowLogOptions{
Destination: ec2.FlowLogDestination_ToS3(),
})
// Only reject traffic and interval every minute.
vpc.addFlowLog(jsii.String("FlowLogCloudWatch"), &FlowLogOptions{
TrafficType: ec2.FlowLogTrafficType_REJECT,
MaxAggregationInterval: ec2.FlowLogMaxAggregationInterval_ONE_MINUTE,
})
Properties
destinationoptionalFlowLogDestinationdestinationoptionalFlowLogDestinationdestinationoptionalFlowLogDestinationDestinationoptionalFlowLogDestinationDestinationoptionalFlowLogDestination#Default: FlowLogDestinationType.toCloudWatchLogs()
Flow log data can be published to CloudWatch Logs or Amazon S3
logFormatoptionalLogFormat[]log_formatoptionaltyping.List[LogFormat]logFormatoptionalList<LogFormat>LogFormatoptionalLogFormat[]LogFormatoptional*[]LogFormat#Default: default log format is used.
notes
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
maxAggregationIntervaloptionalFlowLogMaxAggregationIntervalmax_aggregation_intervaloptionalFlowLogMaxAggregationIntervalmaxAggregationIntervaloptionalFlowLogMaxAggregationIntervalMaxAggregationIntervaloptionalFlowLogMaxAggregationIntervalMaxAggregationIntervaloptionalFlowLogMaxAggregationInterval#Default: FlowLogMaxAggregationInterval.ONE_MINUTES if creating flow logs for Transit Gateway, otherwise FlowLogMaxAggregationInterval.TEN_MINUTES.
When creating flow logs for a Transit Gateway or Transit Gateway Attachment, this property must be ONE_MINUTES.
trafficTypeoptionalFlowLogTrafficTypetraffic_typeoptionalFlowLogTrafficTypetrafficTypeoptionalFlowLogTrafficTypeTrafficTypeoptionalFlowLogTrafficTypeTrafficTypeoptionalFlowLogTrafficType= ALL#You can log traffic that the resource accepts or rejects, or all traffic. When the target is either TransitGateway or TransitGatewayAttachment, setting the traffic type is not possible.