fix(ec2): store and return flow log DestinationOptions (#10047)

CreateFlowLogs stores FileFormat, HiveCompatiblePartitions and PerHourPartition, and DescribeFlowLogs returns them as destinationOptions: an s3 flow log created without them reports plain-text, false, false, a partial request defaults the rest, and a cloud-watch-logs flow log omits the element unless options were sent. A partition flag that is not a boolean is refused. CloudFormation AWS::EC2::FlowLog resolves DestinationOptions whole, so an intrinsic can supply the block, passes it to the flow log, and refuses an update that changes it, as the property is create-only.

Closes #7888
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-12-03 17:26:41 -04:00
1 parent 51767ad056
commit 839826ff50
11 files changed
+487 -24

No files matched your search

@@ -3,6 +3,8 @@ package com.floci.test;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ec2.model.DestinationFileFormat;
import software.amazon.awssdk.services.ec2.model.DestinationOptionsResponse;
import software.amazon.awssdk.services.ec2.model.FlowLog;
import software.amazon.awssdk.services.ec2.model.FlowLogsResourceType;
import software.amazon.awssdk.services.ec2.model.TrafficType;
@@ -61,4 +63,34 @@ class Ec2FlowLogFormatTest {
}
}
}
@Test
@DisplayName("DescribeFlowLogs returns the DestinationOptions the s3 flow log was created with")
void describesTheDestinationOptions() {
try (Ec2Client ec2 = TestFixtures.ec2Client()) {
String vpcId = ec2.createVpc(r -> r.cidrBlock("10.73.0.0/16")).vpc().vpcId();
String flowLogId = null;
try {
flowLogId = ec2.createFlowLogs(r -> r.resourceIds(vpcId)
.resourceType(FlowLogsResourceType.VPC)
.trafficType(TrafficType.ALL)
.logDestinationType("s3")
.logDestination("arn:aws:s3:::flow-logs-bucket")
.destinationOptions(o -> o.fileFormat(DestinationFileFormat.PARQUET)
.hiveCompatiblePartitions(true)
.perHourPartition(true))).flowLogIds().get(0);
DestinationOptionsResponse options = describe(ec2, flowLogId).destinationOptions();
assertThat(options.fileFormat()).isEqualTo(DestinationFileFormat.PARQUET);
assertThat(options.hiveCompatiblePartitions()).isTrue();
assertThat(options.perHourPartition()).isTrue();
} finally {
if (flowLogId != null) {
String id = flowLogId;
ec2.deleteFlowLogs(r -> r.flowLogIds(id));
}
ec2.deleteVpc(r -> r.vpcId(vpcId));
}
}
}
}