class FlowLog (construct)
This page is available in another version. Click here for the v2 documentation.
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.FlowLog |
![]() | software.amazon.awscdk.services.ec2.FlowLog |
![]() | aws_cdk.aws_ec2.FlowLog |
![]() | @aws-cdk/aws-ec2 » FlowLog |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IFlow
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)
});
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. |
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: 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.
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.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
flow | string | The Id of the VPC Flow Log. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
bucket? | IBucket | The S3 bucket 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:
Construct
The construct tree node associated with this construct.
stack
Type:
Stack
The stack in which this resource is defined.
bucket?
Type:
IBucket
(optional)
The S3 bucket 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.