FlowLog

class aws_cdk.aws_ec2.FlowLog(scope, id, *, resource_type, flow_log_name=None, destination=None, log_format=None, max_aggregation_interval=None, traffic_type=None)

Bases: Resource

A VPC flow log.

Resource:

AWS::EC2::FlowLog

ExampleMetadata:

infused

Example:

# tgw: ec2.CfnTransitGateway


ec2.FlowLog(self, "TransitGatewayFlowLog",
    resource_type=ec2.FlowLogResourceType.from_transit_gateway_id(tgw.ref)
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • resource_type (FlowLogResourceType) – The type of resource for which to create the flow log.

  • flow_log_name (Optional[str]) – The name of the FlowLog. Since the FlowLog resource doesn’t support providing a physical name, the value provided here will be recorded in the Name tag. Default: CDK generated name

  • destination (Optional[FlowLogDestination]) – 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 Default: FlowLogDestinationType.toCloudWatchLogs()

  • log_format (Optional[Sequence[LogFormat]]) – 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 Default: - default log format is used.

  • max_aggregation_interval (Optional[FlowLogMaxAggregationInterval]) – The maximum interval of time during which a flow of packets is captured and aggregated into a flow log record. When creating flow logs for a Transit Gateway or Transit Gateway Attachment, this property must be ONE_MINUTES. Default: - FlowLogMaxAggregationInterval.ONE_MINUTES if creating flow logs for Transit Gateway, otherwise FlowLogMaxAggregationInterval.TEN_MINUTES.

  • traffic_type (Optional[FlowLogTrafficType]) – The type of traffic to log. 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. Default: ALL

Methods

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

bucket

The S3 bucket to publish flow logs to.

delivery_stream_arn

The ARN of the Kinesis Data Firehose delivery stream to publish flow logs to.

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

flow_log_id

The Id of the VPC Flow Log.

Attribute:

true

iam_role

The iam role used to publish logs to CloudWatch.

key_prefix

S3 bucket key prefix to publish the flow logs under.

log_group

The CloudWatch Logs LogGroup to publish flow logs to.

node

The tree node.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_flow_log_id(scope, id, flow_log_id)

Import a Flow Log by it’s Id.

Parameters:
  • scope (Construct) –

  • id (str) –

  • flow_log_id (str) –

Return type:

IFlowLog

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool