fix(lambda): refuse function URLs in GovCloud and China (#5615)

The AWS GovCloud (US) User Guide lists "AWS Lambda Function URLs is not
available"
(https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-lambda.html)
and the China guide "Amazon Lambda Function URLs is not available in the
China Regions"
(https://docs.amazonaws.cn/en_us/aws/latest/userguide/lambda.html), but
CreateFunctionUrlConfig created one in every partition, on a host no
source publishes for either of them.

CreateFunctionUrlConfig now refuses a request whose region is in
aws-us-gov or aws-cn with an InvalidParameterValueException, which the
lambda model declares for the operation. No source shows AWS's message,
so the wording is Floci's own, as for the API Gateway EDGE gate. The
AWS::Lambda::Url provisioner creates through the same service method, so
a stack in those partitions fails with that error. Get, Update and Delete
act on an existing config and are unchanged. The ISO and EUSC partitions
are left as they are because no source covers them, and the open
question about the function URL host now names only those two.

The Java compat suite skips LambdaFunctionUrlTest in those two partitions,
so the China partition nightly stays green.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-13 23:58:42 -04:00
1 parent d3999ad416
commit 255162654f
6 files changed
+167 -1

No files matched your search

@@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
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.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.Digests;
@@ -3050,7 +3052,27 @@ public class LambdaService implements ResourceProvider {
// ──────────────────────────── Function URL Config ────────────────────────────
/** The partitions where AWS documents Lambda function URLs as not available. */
private static final Set<String> FUNCTION_URL_UNAVAILABLE_PARTITIONS = Set.of("aws-us-gov", "aws-cn");
/**
* Function URLs are not available in AWS GovCloud (US) or in the China Regions: "AWS Lambda
* Function URLs is not available"
* (https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-lambda.html) and "Amazon
* Lambda Function URLs is not available in the China Regions"
* (https://docs.amazonaws.cn/en_us/aws/latest/userguide/lambda.html). No source shows AWS's
* message for the refusal, so the wording is Floci's own.
*/
private static void requireFunctionUrlsAvailable(String region) {
AwsPartition partition = AwsPartitions.forRegionOrCommercial(region);
if (FUNCTION_URL_UNAVAILABLE_PARTITIONS.contains(partition.id())) {
throw new AwsException("InvalidParameterValueException",
"Function URLs are not available in partition " + partition.id() + ".", 400);
}
}
public LambdaUrlConfig createFunctionUrlConfig(String region, String functionName, String qualifier, Map<String, Object> request) {
requireFunctionUrlsAvailable(region);
validateFunctionUrlQualifier(qualifier);
LambdaArnUtils.ResolvedFunctionRef ref = resolveWithRegion(region, functionName, qualifier);
functionName = ref.name();