aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.37k stars 3.78k forks source link

(ec2): VPC Flow Log `interface-id` format is incorrect #24807

Closed kylelaker closed 1 year ago

kylelaker commented 1 year ago

Describe the bug

In the LogFormat enum-like class, INTERFACE_ID has an invalid value.

https://github.com/aws/aws-cdk/blob/c13a0f1a3820c1b8622c3de687ae52834f8ea614/packages/%40aws-cdk/aws-ec2/lib/vpc-flow-logs.ts#L417-L420

Expected Behavior

When specifying ec2.LogFormat.INTERFACE_ID, the stack should create a valid VPC Flow Logs configuration. ${interface-id should be ${interface-id}.

Current Behavior

The CloudFormation stack fails to create because the format string is incorrect.

Reproduction Steps

    const vpc = new ec2.Vpc(this, 'Vpc', {
      ipAddresses: ec2.IpAddresses.cidr('10.10.10.0/24'),
      flowLogs: {
        vpc: {
          destination: ec2.FlowLogDestination.toCloudWatchLogs(),
          logFormat: [
            ec2.LogFormat.INTERFACE_ID,
          ],
        },
      },
    });

Possible Solution

All the constants should be defined using the ec2.LogFormat.field static method instead of the constructor; this will ensure the formatting is correct (and a } isn't missing).

Additional Information/Context

Workaround: use ec2.LogFormat.field('interface-id') instead.

CDK CLI Version

2.70.0

Framework Version

No response

Node.js Version

16

OS

Linux

Language

Typescript

Language Version

No response

Other information

No response

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.