mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
feat(lambdaweb): serve the MultiRegion global domain in the default region (#6460)
* feat(lambdaweb): serve the MultiRegion global domain in the default region AWS serves the global domain from the region nearest the caller. Floci now takes floci.default-region for where the caller is. The global domain is served in that region when the endpoint lists it, and in the home region otherwise. The environment, logs, metrics, SigV4 and aws:RequestedRegion then use that region, as on AWS. * fix(lambdaweb): use the serving region as aws:RequestedRegion for CloudFront A CloudFront origin request got the home region from the endpoint ARN. On AWS it is the region that serves the request, for the global domain and for a regional domain alike.
This commit is contained in:
1 parent
f49376f538
commit
acb9fd2cd6
6 files changed
+88
-8
No files matched your search
@@ -137,6 +137,8 @@ public class LambdaWebIamAuth {
|
||||
Map<String, List<String>> context = resourceContext(target);
|
||||
context.putAll(IamConditionContextResolver.serviceCallContext(principal, endpointArn, target.accountId(),
|
||||
distributionArn, AwsArnUtils.parse(distributionArn).accountId()));
|
||||
// The endpoint ARN names the home region, not the region that serves.
|
||||
context.put("aws:RequestedRegion", List.of(target.servingRegion()));
|
||||
String policy = target.function().policy;
|
||||
boolean allowed = evaluator.evaluateServicePrincipal(isBlank(policy) ? null : List.of(policy), principal,
|
||||
ACTION, endpointArn, context) == Decision.ALLOW;
|
||||
|
||||
@@ -230,11 +230,17 @@ public class LambdaWebService implements Resettable {
|
||||
return Optional.ofNullable(originHosts.get(host));
|
||||
}
|
||||
|
||||
/** Floci serves the MultiRegion global domain in the home region. */
|
||||
/**
|
||||
* AWS serves the MultiRegion global domain in the region nearest the caller. Floci takes the default region for
|
||||
* that when the endpoint has it, and the home region otherwise.
|
||||
*/
|
||||
private void indexDomains(WebFunction fn, WebFunctionEndpoint endpoint) {
|
||||
AwsArnUtils.Arn arn = AwsArnUtils.parse(fn.functionArn);
|
||||
String defaultRegion = regionResolver.getDefaultRegion();
|
||||
String servingRegion = "MultiRegion".equals(endpoint.endpointType) && endpoint.regions.contains(defaultRegion)
|
||||
? defaultRegion : arn.region();
|
||||
index(endpoint.domainName, new EndpointLocator(arn.accountId(), arn.region(), fn.functionName,
|
||||
endpoint.endpointName, arn.region()));
|
||||
endpoint.endpointName, servingRegion));
|
||||
endpoint.regionalDomainNames.forEach((region, domain) -> index(domain, new EndpointLocator(arn.accountId(),
|
||||
arn.region(), fn.functionName, endpoint.endpointName, region)));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user