Skip to content

ec2: flowLogName property in FlowLog construct does not work #26370

@tam0ri

Description

@tam0ri

Describe the bug

FlowLog L2 construct has flowLogName property.
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.FlowLog.html

This is only assigned to physicalName here.

super(scope, id, {
physicalName: props.flowLogName,
});

However, we can't define physical name for AWS::EC2::FlowLog resource. The pysical name for VPC Flow Logs is always automatically generated id.

So, currently flowLogName property is meaningless property.

Expected Behavior

In VPC console, a tag value for Name key is shown in Name column as below.

flowlog-console

So, FlowLog L2 construct should add Name tag like VPC or Instance L2 construct.

Tags.of(this).add(NAME_TAG, props.vpcName || this.node.path);

Tags.of(this).add(NAME_TAG, props.instanceName || this.node.path);

Current Behavior

The value of flowLogName property is never referred in generated CloudFormation template.

Reproduction Steps

We can reproduce it with the following snippet.

    const vpc = ec2.Vpc.fromLookup(this, 'Vpc', {
      isDefault: true,
    });

    new ec2.FlowLog(this, 'FlowLog', {
      flowLogName: 'CustomFlowLogName',
      resourceType: ec2.FlowLogResourceType.fromVpc(vpc),
    });

Possible Solution

Adding Name tag with the value of flowLogName property.

Additional Information/Context

No response

CDK CLI Version

v2.87.0

Framework Version

No response

Node.js Version

v18.16.0

OS

Amazon Linux 2

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions