class FlowLog (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.FlowLog |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#FlowLog |
![]() | software.amazon.awscdk.services.ec2.FlowLog |
![]() | aws_cdk.aws_ec2.FlowLog |
![]() | aws-cdk-lib » aws_ec2 » FlowLog |
Implements
IConstruct
, IDependable
, IResource
, IFlow
A VPC flow log.
Example
declare const tgw: ec2.CfnTransitGateway;
new ec2.FlowLog(this, 'TransitGatewayFlowLog', {
resourceType: ec2.FlowLogResourceType.fromTransitGatewayId(tgw.ref)
})
Initializer
new FlowLog(scope: Construct, id: string, props: FlowLogProps)
Parameters
- scope
Construct
- id
string
- props
Flow
Log Props
Construct Props
Name | Type | Description |
---|---|---|
resource | Flow | The type of resource for which to create the flow log. |
destination? | Flow | Specifies the type of destination to which the flow log data is to be published. |
flow | string | The name of the FlowLog. |
log | Log [] | The fields to include in the flow log record, in the order in which they should appear. |
max | Flow | The maximum interval of time during which a flow of packets is captured and aggregated into a flow log record. |
traffic | Flow | The type of traffic to log. |
resourceType
Type:
Flow
The type of resource for which to create the flow log.
destination?
Type:
Flow
(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: CDK generated name)
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.
logFormat?
Type:
Log
[]
(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()
.
maxAggregationInterval?
Type:
Flow
(optional, default: FlowLogMaxAggregationInterval.ONE_MINUTES if creating flow logs for Transit Gateway, otherwise FlowLogMaxAggregationInterval.TEN_MINUTES.)
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.
trafficType?
Type:
Flow
(optional, default: ALL)
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.
See also: https://docs.aws.amazon.com/vpc/latest/tgw/working-with-flow-logs.html
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
flow | string | The Id of the VPC Flow Log. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
bucket? | IBucket | The S3 bucket to publish flow logs to. |
delivery | string | The ARN of the Kinesis Data Firehose delivery stream to publish flow logs to. |
iam | IRole | The iam role used to publish logs to CloudWatch. |
key | string | S3 bucket key prefix to publish the flow logs under. |
log | ILog | The CloudWatch Logs LogGroup to publish flow logs to. |
env
Type:
Resource
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.
flowLogId
Type:
string
The Id of the VPC Flow Log.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
bucket?
Type:
IBucket
(optional)
The S3 bucket to publish flow logs to.
deliveryStreamArn?
Type:
string
(optional)
The ARN of the Kinesis Data Firehose delivery stream to publish flow logs to.
iamRole?
Type:
IRole
(optional)
The iam role used to publish logs to CloudWatch.
keyPrefix?
Type:
string
(optional)
S3 bucket key prefix to publish the flow logs under.
logGroup?
Type:
ILog
(optional)
The CloudWatch Logs LogGroup to publish flow logs to.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import a Flow Log by it's Id. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
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
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromFlowLogId(scope, id, flowLogId)
public static fromFlowLogId(scope: Construct, id: string, flowLogId: string): IFlowLog
Parameters
- scope
Construct
- id
string
- flowLogId
string
Returns
Import a Flow Log by it's Id.