fix(apigateway): resolve _user_request_ APIs created outside default region (#1032)

Signed-off-by: JonghyeokNam <njh9750@naver.com>
This commit is contained in:
JonghyeokNam authored and GitHub committed 2026-05-29 01:00:07 -05:00
1 parent 34084fef87
commit d12612c175
3 files changed
+216 -1

No files matched your search

@@ -240,6 +240,12 @@ public class ApiGatewayExecuteController {
return dispatchV2(httpMethod, apiId, stageName, proxy, headers, uriInfo, body, region);
}
// Resolve region for unsigned data-plane requests
String auth = headers.getHeaderString("Authorization");
if (auth == null || auth.isBlank()) {
region = apiGatewayService.resolveRestApiRegion(region, apiId);
}
// Verify API and stage exist
Stage stage;
try {
@@ -191,6 +191,18 @@ public class ApiGatewayService {
.orElseThrow(() -> new AwsException("NotFoundException", "Invalid API id specified", 404));
}
public String resolveRestApiRegion(String preferredRegion, String apiId) {
if (apiStore.get(apiKey(preferredRegion, apiId)).isPresent()) {
return preferredRegion;
}
return apiStore.keys().stream()
.filter(k -> k.endsWith("::" + apiId))
.map(k -> k.substring(0, k.indexOf("::")))
.findFirst()
.orElse(preferredRegion);
}
public List<RestApi> getRestApis(String region) {
String prefix = region + "::";
return apiStore.scan(k -> k.startsWith(prefix));