fix(ec2): keep the tags CreateFlowLogs is given (#6890)

* fix(ec2): keep the tags CreateFlowLogs is given

CreateFlowLogs dropped its vpc-flow-log TagSpecification, and
DescribeFlowLogs had no tagSet, so Terraform's aws_flow_log tags never
read back and every plan after apply wanted to add them again. The tags
are now stored with the flow log and returned.

* test(ec2): read a flow log's tags back through the AWS SDK
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-28 22:58:24 -04:00
1 parent c0d1767ec0
commit 8ececd84b4
3 files changed
+89 -1

No files matched your search

@@ -1994,9 +1994,13 @@ public class Ec2QueryHandler {
.start("CreateFlowLogsResponse", AwsNamespaces.EC2)
.elem("requestId", UUID.randomUUID().toString())
.start("flowLogIdSet");
List<Tag> flowLogTags = parseTagsForResource(p, "vpc-flow-log");
for (String resourceId : resourceIds) {
FlowLog fl = flowLogService.createFlowLog(region, resourceId, resourceType, trafficType,
logDestinationType, logDestination, deliverLogsPermissionArn, logFormat, maxAgg);
if (!flowLogTags.isEmpty()) {
service.createTags(region, List.of(fl.getFlowLogId()), flowLogTags);
}
xml.elem("item", fl.getFlowLogId());
}
xml.end("flowLogIdSet")
@@ -2029,6 +2033,7 @@ public class Ec2QueryHandler {
.elem("deliverLogsStatus", fl.getDeliverLogsStatus())
.elem("maxAggregationInterval", String.valueOf(fl.getMaxAggregationInterval()))
.elem("creationTime", ISO_FMT.format(fl.getCreationTime()))
.raw(tagSetXml(service.resourceTags(region, fl.getFlowLogId())))
.end("item");
}
xml.end("flowLogSet").end("DescribeFlowLogsResponse");