mirror of
https://github.com/floci-io/floci.git
synced 2026-12-06 03:28:18 -05:00
fix(ec2): derive flow log az-id the way subnets do (#5238)
Flow log records derived az-id with a mapping of their own (use1-az1, and cnnorth1-az1 for China), while subnets and DescribeAvailabilityZones derive zone ids with Ec2Service.zoneIdForZoneName (us-east-1-az1), so a record's az-id never matched the AvailabilityZoneId of the subnet it came from. Flow logs now use the same derivation in every region.
This commit is contained in:
1 parent
bcfb9c786c
commit
7f5a332620
2 files changed
+34
-26
No files matched your search
@@ -593,27 +593,13 @@ public class FlowLogService {
|
||||
return ports[ThreadLocalRandom.current().nextInt(ports.length)];
|
||||
}
|
||||
|
||||
/** Map a region + az letter to a plausible AWS az-id (e.g. us-east-1a -> use1-az1). */
|
||||
/**
|
||||
* The zone id of the ENI's zone, derived exactly as subnets and DescribeAvailabilityZones
|
||||
* derive it ({@link Ec2Service#zoneIdForZoneName}), so a record's {@code az-id} matches the
|
||||
* {@code AvailabilityZoneId} of the subnet it came from, in every region and partition.
|
||||
*/
|
||||
private static String azId(String region, String az) {
|
||||
String code = switch (region == null ? "" : region) {
|
||||
case "us-east-1" -> "use1";
|
||||
case "us-east-2" -> "use2";
|
||||
case "us-west-1" -> "usw1";
|
||||
case "us-west-2" -> "usw2";
|
||||
case "eu-west-1" -> "euw1";
|
||||
case "eu-central-1" -> "euc1";
|
||||
case "ap-southeast-1" -> "apse1";
|
||||
case "ap-southeast-2" -> "apse2";
|
||||
default -> region == null ? "use1" : region.replaceAll("[^a-z0-9]", "");
|
||||
};
|
||||
int n = 1;
|
||||
if (az != null && !az.isEmpty()) {
|
||||
char last = az.charAt(az.length() - 1);
|
||||
if (last >= 'a' && last <= 'f') {
|
||||
n = (last - 'a') + 1;
|
||||
}
|
||||
}
|
||||
return code + "-az" + n;
|
||||
return region == null ? null : Ec2Service.zoneIdForZoneName(region, az);
|
||||
}
|
||||
|
||||
private static String nz(String s) {
|
||||
|
||||
Reference in new issue
Block a user