aws / aws/aws-cdk

(aws-ec2): FlowLog DestinationOptions have wrong casing

Open
#25,432 5 comments 2 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 bug effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When I create a FlowLog like so:

```ts
const flowLog = new ec2.FlowLog(this, "FlowLog", {
resourceType: {
resourceType: "TransitGateway",
resourceId: this.transitGateway.attrId,
},
destination: ec2.FlowLogDestination.toS3(vpcFlowLogBucket, undefined, {
fileFormat: ec2.FlowLogFileFormat.PLAIN_TEXT,
hiveCompatiblePartitions: false,
perHourPartition: false,
}),
});
```

the destination options are not set correctly

### Expected Behavior

When setting the options [here](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ec2/lib/vpc-flow-logs.ts#L747) they should be first transformed to pascal case

### Current Behavior

During deploy time I get the following warnings:

```bash
transit-gateway-dev | 1 | 8:05:55 AM | UPDATE_IN_PROGRESS | AWS::EC2::FlowLog | FlowLog/FlowLog (FlowLog3CB084E9) Resource template validation failed for resource FlowLog3CB084E9 as the template has invalid properties. Please refer to the resource documentation to fix the template.
Properties validation failed for resource FlowLog3CB084E9 with message:
#/DestinationOptions: required key [FileFormat] not found
#/DestinationOptions: required key [HiveCompatiblePartitions] not found
#/DestinationOptions: required key [PerHourPartition] not found
#/DestinationOptions: extraneous key [hiveCompatiblePartitions] is not permitted
#/DestinationOptions: extraneous key [perHourPartition] is not permitted
#/DestinationOptions: extraneous key [fileFormat] is not permitted
```

### Reproduction Steps

Deploy the above resource

### Possible Solution

```diff
- destinationOptions: destinationConfig.destinationOptions,
+ destinationOptions: {
+ FileFormat: destinationConfig.destinationOptions.fileFormat,
+ HiveCompatiblePartitions: destinationConfig.destinationOptions.hiveCompatiblePartitions,
+ PerHourPartition: destinationConfig.destinationOptions.perHourPartition,
+ }
```

### Additional Information/Context

_No response_

### CDK CLI Version

2.77.0

### Framework Version

2.77.0

### Node.js Version

18

### OS

MacOS

### Language

Typescript

### Language Version

TypeScript 5.0.4

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Open packages/aws-cdk-lib/aws-ec2/lib/vpc-flow-logs.ts around line 747 and inspect how destinationOptions is emitted. Reproduce the reported FlowLog deployment with the shown TypeScript configuration, then verify the synthesized DestinationOptions use the CloudFormation property names and no lowercase keys remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.