Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ec2): add v7 VPC flow log record fields #30229

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ class TestStack extends Stack {
LogFormat.PKT_DST_AWS_SERVICE,
LogFormat.FLOW_DIRECTION,
LogFormat.TRAFFIC_PATH,
LogFormat.ECS_CLUSTER_ARN,
LogFormat.ECS_CLUSTER_NAME,
LogFormat.ECS_CONTAINER_INSTANCE_ARN,
LogFormat.ECS_CONTAINER_INSTANCE_ID,
LogFormat.ECS_CONTAINER_ID,
LogFormat.ECS_SECOND_CONTAINER_ID,
LogFormat.ECS_SERVICE_NAME,
LogFormat.ECS_TASK_DEFINITION_ARN,
LogFormat.ECS_TASK_ARN,
LogFormat.ECS_TASK_ID,
],
});

Expand Down
56 changes: 56 additions & 0 deletions packages/aws-cdk-lib/aws-ec2/lib/vpc-flow-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export enum FlowLogMaxAggregationInterval {

/**
* The following table describes all of the available fields for a flow log record.
* See https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-log-records
*/
export class LogFormat {
/**
Expand Down Expand Up @@ -646,6 +647,61 @@ export class LogFormat {
*/
public static readonly TRAFFIC_PATH = LogFormat.field('traffic-path');

/**
* AWS Resource Name (ARN) of the ECS cluster if the traffic is from a running ECS task.
*/
public static readonly ECS_CLUSTER_ARN = LogFormat.field('ecs-cluster-arn');

/**
* Name of the ECS cluster if the traffic is from a running ECS task.
*/
public static readonly ECS_CLUSTER_NAME = LogFormat.field('ecs-cluster-name');

/**
* ARN of the ECS container instance if the traffic is from a running ECS task on an EC2 instance.
* If the capacity provider is AWS Fargate, this field will be '-'.
*/
public static readonly ECS_CONTAINER_INSTANCE_ARN = LogFormat.field('ecs-container-instance-arn');

/**
* ID of the ECS container instance if the traffic is from a running ECS task on an EC2 instance.
* If the capacity provider is AWS Fargate, this field will be '-'.
*/
public static readonly ECS_CONTAINER_INSTANCE_ID = LogFormat.field('ecs-container-instance-id');

/**
* Docker runtime ID of the container if the traffic is from a running ECS task.
* If there are one or more containers in the ECS task, this will be the docker runtime ID of the first container.
*/
public static readonly ECS_CONTAINER_ID = LogFormat.field('ecs-container-id');

/**
* Docker runtime ID of the container if the traffic is from a running ECS task.
* If there are more than one containers in the ECS task, this will be the Docker runtime ID of the second container.
*/
public static readonly ECS_SECOND_CONTAINER_ID = LogFormat.field('ecs-second-container-id');

/**
* Name of the ECS service if the traffic is from a running ECS task and the ECS task is started by an ECS service.
* If the ECS task is not started by an ECS service, this field will be '-'.
*/
public static readonly ECS_SERVICE_NAME = LogFormat.field('ecs-service-name');

/**
* ARN of the ECS task definition if the traffic is from a running ECS task.
*/
public static readonly ECS_TASK_DEFINITION_ARN = LogFormat.field('ecs-task-definition-arn');

/**
* ARN of the ECS task if the traffic is from a running ECS task.
*/
public static readonly ECS_TASK_ARN = LogFormat.field('ecs-task-arn');

/**
* ID of the ECS task if the traffic is from a running ECS task.
*/
public static readonly ECS_TASK_ID = LogFormat.field('ecs-task-id');

/**
* The default format.
*/
Expand Down
10 changes: 10 additions & 0 deletions packages/aws-cdk-lib/aws-ec2/test/vpc-flow-logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,16 @@ test('log format for built-in types is correct', () => {
LogFormat.PKT_DST_AWS_SERVICE,
LogFormat.FLOW_DIRECTION,
LogFormat.TRAFFIC_PATH,
LogFormat.ECS_CLUSTER_ARN,
LogFormat.ECS_CLUSTER_NAME,
LogFormat.ECS_CONTAINER_INSTANCE_ARN,
LogFormat.ECS_CONTAINER_INSTANCE_ID,
LogFormat.ECS_CONTAINER_ID,
LogFormat.ECS_SECOND_CONTAINER_ID,
LogFormat.ECS_SERVICE_NAME,
LogFormat.ECS_TASK_DEFINITION_ARN,
LogFormat.ECS_TASK_ARN,
LogFormat.ECS_TASK_ID,
],
});

Expand Down
Loading