# FlowLogDestination

The destination type for the flow log.

Obtainable from: FlowLogDestination.toCloudWatchLogs, FlowLogDestination.toFirehose, FlowLogDestination.toKinesisDataFirehoseDestination, FlowLogDestination.toS3

- Source: [`aws-ec2/lib/vpc-flow-logs.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-ec2/lib/vpc-flow-logs.ts#L206)
- Type last changed: v2.238.0 · 9 Feb 2026

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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)
});
```

Golang:

```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

TypeScript:

```ts
new FlowLogDestination()
```

Python:

```python
FlowLogDestination()
```

Java:

```java
new FlowLogDestination()
```

C# / .NET:

```csharp
new FlowLogDestination()
```

Golang:

```go
NewFlowLogDestination()
```

## Methods

- `bind(scope: Construct, flowLog: FlowLog): FlowLogDestinationConfig` — Generates a flow log destination configuration.

- `toCloudWatchLogs(logGroup?: ILogGroupRef, iamRole?: IRole): FlowLogDestination // chainable` (static) — Use CloudWatch logs as the destination.

- `toFirehose(deliveryStream: IDeliveryStreamRef, iamRole?: IRole): FlowLogDestination // chainable` (static) — Use Amazon Data Firehose as the destination.

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

  **Parameters**

  - `deliveryStream` — the Amazon Data Firehose delivery stream to publish logs to.
  - `iamRole` — the IAM Role for cross account log delivery.

- `toKinesisDataFirehoseDestination(deliveryStreamArn: string): FlowLogDestination // chainable` (static) — use `toFirehose`

  **Parameters**

  - `deliveryStreamArn` — the ARN of Amazon Data Firehose delivery stream to publish logs to.

- `toS3(bucket?: IBucket, keyPrefix?: string, options?: S3DestinationOptions): FlowLogDestination // chainable` (static) — Use S3 as the destination.

  **Parameters**

  - `bucket` — optional s3 bucket to publish logs to.
  - `keyPrefix` — optional prefix within the bucket to write logs to.
  - `options` — additional s3 destination options.
