Skip to content
v2.277.0

FlowLogDestination Class ​

The destination type for the flow log.

Example ​

ts
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)
});
python
# vpc: ec2.Vpc


log_group = logs.LogGroup(self, "MyCustomLogGroup")

role = iam.Role(self, "MyCustomRole",
    assumed_by=iam.ServicePrincipal("vpc-flow-logs.amazonaws.com")
)

ec2.FlowLog(self, "FlowLog",
    resource_type=ec2.FlowLogResourceType.from_vpc(vpc),
    destination=ec2.FlowLogDestination.to_cloud_watch_logs(log_group, role)
)
java
Vpc vpc;


LogGroup logGroup = new LogGroup(this, "MyCustomLogGroup");

Role role = Role.Builder.create(this, "MyCustomRole")
        .assumedBy(new ServicePrincipal("vpc-flow-logs.amazonaws.com"))
        .build();

FlowLog.Builder.create(this, "FlowLog")
        .resourceType(FlowLogResourceType.fromVpc(vpc))
        .destination(FlowLogDestination.toCloudWatchLogs(logGroup, role))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;


var logGroup = new LogGroup(this, "MyCustomLogGroup");

var role = new Role(this, "MyCustomRole", new RoleProps {
    AssumedBy = new ServicePrincipal("vpc-flow-logs.amazonaws.com")
});

new FlowLog(this, "FlowLog", new FlowLogProps {
    ResourceType = FlowLogResourceType.FromVpc(vpc),
    Destination = FlowLogDestination.ToCloudWatchLogs(logGroup, role)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc


logGroup := logs.NewLogGroup(this, jsii.String("MyCustomLogGroup"))

role := iam.NewRole(this, jsii.String("MyCustomRole"), &RoleProps{
	AssumedBy: iam.NewServicePrincipal(jsii.String("vpc-flow-logs.amazonaws.com")),
})

ec2.NewFlowLog(this, jsii.String("FlowLog"), &FlowLogProps{
	ResourceType: ec2.FlowLogResourceType_FromVpc(vpc),
	Destination: ec2.FlowLogDestination_ToCloudWatchLogs(logGroup, role),
})

Initializer ​

ts
new FlowLogDestination()
python
FlowLogDestination()
java
new FlowLogDestination()
csharp
new FlowLogDestination()
go
NewFlowLogDestination()

Methods ​

bind(scope: Construct, flowLog: FlowLog): FlowLogDestinationConfigdef bind(self, scope: Construct, flow_log: FlowLog) -> FlowLogDestinationConfigpublic FlowLogDestinationConfig bind(Construct scope, FlowLog flowLog)public FlowLogDestinationConfig Bind(Construct scope, FlowLog flowLog)func Bind(Scope Construct, FlowLog FlowLog) FlowLogDestinationConfig#
Generates a flow log destination configuration.
toCloudWatchLogs(logGroup?: ILogGroupRef, iamRole?: IRole): FlowLogDestination // chainable@staticmethod def to_cloud_watch_logs(log_group: typing.Optional[ILogGroupRef] = None, iam_role: typing.Optional[IRole] = None) -> FlowLogDestinationpublic static FlowLogDestination toCloudWatchLogs(ILogGroupRef logGroup, IRole iamRole)public static FlowLogDestination ToCloudWatchLogs(ILogGroupRef? logGroup = null, IRole? iamRole = null)func ToCloudWatchLogs(LogGroup ILogGroupRef, IamRole IRole) FlowLogDestinationstatic#
Use CloudWatch logs as the destination.
toFirehose(deliveryStream: IDeliveryStreamRef, iamRole?: IRole): FlowLogDestination // chainable@staticmethod def to_firehose(delivery_stream: IDeliveryStreamRef, iam_role: typing.Optional[IRole] = None) -> FlowLogDestinationpublic static FlowLogDestination toFirehose(IDeliveryStreamRef deliveryStream, IRole iamRole)public static FlowLogDestination ToFirehose(IDeliveryStreamRef deliveryStream, IRole? iamRole = null)func ToFirehose(DeliveryStream IDeliveryStreamRef, IamRole IRole) FlowLogDestinationstatic#
Use Amazon Data Firehose as the destination.

If the delivery stream and the VPC are in different account, you must specify iamRole.

2 parameters

Parameters

  • deliveryStreamdelivery_streamdeliveryStreamdeliveryStreamDeliveryStream — the Amazon Data Firehose delivery stream to publish logs to.
  • iamRoleiam_roleiamRoleiamRoleIamRole — the IAM Role for cross account log delivery.
toKinesisDataFirehoseDestination(deliveryStreamArn: string): FlowLogDestination // chainable@staticmethod def to_kinesis_data_firehose_destination(delivery_stream_arn: str) -> FlowLogDestinationpublic static FlowLogDestination toKinesisDataFirehoseDestination(String deliveryStreamArn)public static FlowLogDestination ToKinesisDataFirehoseDestination(string deliveryStreamArn)func ToKinesisDataFirehoseDestination(DeliveryStreamArn *string) FlowLogDestinationstaticdeprecated#
use `toFirehose`
1 parameter

Parameters

  • deliveryStreamArndelivery_stream_arndeliveryStreamArndeliveryStreamArnDeliveryStreamArn — the ARN of Amazon Data Firehose delivery stream to publish logs to.
toS3(bucket?: IBucket, keyPrefix?: string, options?: S3DestinationOptions): FlowLogDestination // chainable@staticmethod def to_s3(bucket: typing.Optional[IBucket] = None, key_prefix: typing.Optional[str] = None, options: typing.Optional[S3DestinationOptions] = None) -> FlowLogDestinationpublic static FlowLogDestination toS3(IBucket bucket, String keyPrefix, S3DestinationOptions options)public static FlowLogDestination ToS3(IBucket? bucket = null, string? keyPrefix = null, S3DestinationOptions? options = null)func ToS3(Bucket IBucket, KeyPrefix *string, Options S3DestinationOptions) FlowLogDestinationstatic#
Use S3 as the destination.
3 parameters

Parameters

  • bucketbucketbucketbucketBucket — optional s3 bucket to publish logs to.
  • keyPrefixkey_prefixkeyPrefixkeyPrefixKeyPrefix — optional prefix within the bucket to write logs to.
  • optionsoptionsoptionsoptionsOptions — additional s3 destination options.