fix(lambda): resolve partition for layer lookup and principals (#6947)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-29 16:32:20 -04:00
1 parent b73f643d3f
commit b063f7ff8c
4 files changed
+35 -5

No files matched your search

@@ -3,7 +3,6 @@ package io.github.hectorvent.floci.services.lambda;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.core.common.FileTrees;
import io.github.hectorvent.floci.core.common.PaginatedResult;
import io.github.hectorvent.floci.core.common.RegionResolver;
@@ -422,7 +421,7 @@ public class LambdaLayerService {
if (arn == null || accountId == null || accountId.isBlank()
|| functionRegion == null || functionRegion.isBlank()
|| !"lambda".equals(arn.service())
|| AwsArnUtils.isForeignPartition(arn, AwsRegions.partitionFor(functionRegion))
|| AwsArnUtils.isForeignPartition(arn, regionResolver.partitionForRegion(functionRegion))
|| AwsArnUtils.isForeignAccount(arn, accountId)) {
return null;
}
@@ -9,7 +9,6 @@ import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.AwsPartition;
import io.github.hectorvent.floci.core.common.AwsPartitions;
import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.core.common.CustomResourceLiveness;
import io.github.hectorvent.floci.core.common.PaginatedResult;
import io.github.hectorvent.floci.core.common.Pagination;
@@ -3882,7 +3881,7 @@ public class LambdaService implements ResourceProvider {
* (such as {@code *}) is kept as given. ARNs are checked first because an IAM role, user or
* session name may contain a dot.
*/
private static Object permissionPrincipal(String principal, String region) {
private Object permissionPrincipal(String principal, String region) {
if (principal == null) {
return null;
}
@@ -3890,7 +3889,7 @@ public class LambdaService implements ResourceProvider {
return Map.of("AWS", principal);
}
if (ACCOUNT_ID_PATTERN.matcher(principal).matches()) {
String partition = AwsRegions.partitionFor(region);
String partition = regionResolver.partitionForRegion(region);
return Map.of("AWS", AwsArnUtils.Arn.global(partition, "iam", principal, "root").toString());
}
if (principal.contains(".")) {