Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

feat(core): partition foundation from botocore's published partition data (#4317)

Hector Ventura0dd080a46fb4
diff --git a/.github/workflows/partition-literals.yml b/.github/workflows/partition-literals.yml
index 39aa463019..8dc0451070 100644
--- a/.github/workflows/partition-literals.yml
+++ b/.github/workflows/partition-literals.yml
@@ -5,14 +5,18 @@ name: Partition Literals
# hardcoded arn:aws: prefixes, amazonaws.com hosts, hosted-zone ids and hand-rolled
# partition regexes in src/main/java against the checked-in per-file baseline: a
# literal in a new file fails, growth in an existing file fails, and a drop fails until
-# the baseline is regenerated so the remaining count stays exact. Python-only, so it is
-# fast and independent of the Java build job.
+# the baseline is regenerated so the remaining count stays exact. The second job checks
+# that the vendored partition data (src/main/resources/aws/partitions.json) still matches
+# what tools/aws/regen_partitions.py produces from the pinned botocore release. Python-only,
+# so both are fast and independent of the Java build job.
on:
pull_request:
paths:
- 'src/main/java/**'
+ - 'src/main/resources/aws/**'
- 'tools/partition/**'
+ - 'tools/aws/**'
- 'Makefile'
- '.github/workflows/partition-literals.yml'
push:
@@ -20,7 +24,9 @@ on:
- main
paths:
- 'src/main/java/**'
+ - 'src/main/resources/aws/**'
- 'tools/partition/**'
+ - 'tools/aws/**'
- 'Makefile'
- '.github/workflows/partition-literals.yml'
@@ -56,3 +62,24 @@ jobs:
- name: Print the remaining-literal audit
if: always()
run: make partition-audit
+
+ aws-data:
+ name: Vendored partition data in sync
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Set up Python
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: "3.x"
+
+ - name: Install the pinned botocore
+ run: pip install -r tools/aws/requirements.txt
+
+ - name: Run generator tests
+ run: make aws-data-test
+
+ - name: Check partitions.json against a fresh generation
+ run: make aws-data-check
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f686420ff3..f1dc9da919 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -330,6 +330,11 @@ DNS suffix; a literal that really is partition-invariant goes in
`tools/partition/allowlist.yaml` with a reason, or ends its line with
`// partition-literal: <reason>`.
+The partition catalog itself (`src/main/resources/aws/partitions.json`: ids, DNS suffixes,
+regions, opt-in flags, global endpoints) is generated from botocore's published data by
+`make aws-data-sync` and checked by `make aws-data-check` in CI; never hand-edit it. Bump
+`tools/aws/requirements.txt` when regenerating from a newer botocore.
+
## Reporting Security Issues
Please do **not** open public issues for security vulnerabilities. Report them privately by emailing the maintainer or using [GitHub private vulnerability reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).
diff --git a/Makefile b/Makefile
index 6945e9cb5a..c0f5a687ee 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,9 @@
# Partition literals: hardcoded arn:aws: prefixes, amazonaws.com hosts and hosted-zone
# ids in src/main are inventoried against tools/partition/baseline.tsv so the
# commercial-partition assumption can only shrink. See tools/partition/.
+#
+# AWS partition data: src/main/resources/aws/partitions.json is generated from botocore's
+# published partition metadata (plus two CDK region rules) by tools/aws/regen_partitions.py.
PYTHON ?= python3
@@ -38,7 +41,8 @@ PREFIX ?= $(HOME)/.local
.DEFAULT_GOAL := help
.PHONY: help dev build test native native-host run-native native-install native-image native-up native-down native-logs clean-sidecars clean-volumes compat docker-tests \
- docs-sync docs-check docs-test partition-check partition-baseline partition-audit partition-test
+ docs-sync docs-check docs-test partition-check partition-baseline partition-audit partition-test \
+ aws-data-sync aws-data-check aws-data-test
help: ## List the targets below
@grep -hE '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-14s %s\n", $$1, $$2}'
@@ -166,3 +170,17 @@ partition-audit: ## Print the per-package table of remaining partition literals
partition-test: ## Run the partition tooling's unit tests
$(PYTHON) -m pytest tools/partition -q
+
+aws-data-sync: ## Regenerate src/main/resources/aws/partitions.json from botocore (commit the result)
+ $(PYTHON) tools/aws/regen_partitions.py
+
+aws-data-check: ## CI gate: the vendored partition data must match a fresh generation
+ @$(PYTHON) tools/aws/regen_partitions.py --check || { \
+ echo ""; \
+ echo "error: src/main/resources/aws/partitions.json is out of date."; \
+ echo " Run 'make aws-data-sync' and commit the result."; \
+ exit 1; \
+ }
+
+aws-data-test: ## Run the partition-data generator's unit tests
+ $(PYTHON) -m pytest tools/aws -q
diff --git a/docs/configuration/advanced/application-yml.md b/docs/configuration/advanced/application-yml.md
index c108c91494..86352a6bf5 100644
--- a/docs/configuration/advanced/application-yml.md
+++ b/docs/configuration/advanced/application-yml.md
@@ -38,8 +38,10 @@ The block below mirrors `src/main/resources/application.yml`, it's the effective
floci:
base-url: "http://localhost:4566" # Used to build response URLs (SQS QueueUrl, SNS endpoints, etc.)
# hostname: "" # When set, overrides the host in base-url for multi-container Docker
- default-region: us-east-1
+ default-region: us-east-1 # Also selects the partition (cn-north-1 -> aws-cn)
default-account-id: "000000000000"
+ partitions:
+ # id: aws # Pin the partition explicitly; derived from default-region when unset
storage:
mode: memory # memory | persistent | hybrid | wal
diff --git a/docs/configuration/environment-variables.md b/docs/configuration/environment-variables.md
index 632cf53fb3..b743ad3a93 100644
--- a/docs/configuration/environment-variables.md
+++ b/docs/configuration/environment-variables.md
@@ -10,7 +10,8 @@ Floci is configured exclusively through environment variables. Every option belo
|---|---|---|
| `FLOCI_BASE_URL` | `http://localhost:4566` | Base URL embedded in response fields (SQS `QueueUrl`, pre-signed URLs, etc.) |
| `FLOCI_HOSTNAME` | _(none)_ | Overrides only the hostname part of `FLOCI_BASE_URL`. Set to the Compose service name (e.g. `floci`) so other containers can reach Floci by DNS |
-| `FLOCI_DEFAULT_REGION` | `us-east-1` | AWS region used in ARNs and API responses |
+| `FLOCI_DEFAULT_REGION` | `us-east-1` | AWS region used in ARNs and API responses when a request names none. Also selects the deployment's partition (`cn-north-1` means `aws-cn`), see [AWS Partitions](./partitions.md) |
+| `FLOCI_PARTITIONS_ID` | _(derived)_ | Pins the partition (`aws`, `aws-cn`, `aws-us-gov`, `aws-iso`, `aws-iso-b`, `aws-iso-e`, `aws-iso-f`, `aws-eusc`). Startup refuses a value that contradicts `FLOCI_DEFAULT_REGION` |
| `FLOCI_DEFAULT_ACCOUNT_ID` | `000000000000` | Fallback account ID used in ARNs when the request's access key is not exactly 12 digits. When the access key IS 12 digits, it is used directly as the account ID — see [Multi-Account Isolation](./multi-account.md) |
| `FLOCI_DEFAULT_AVAILABILITY_ZONE` | `us-east-1a` | Availability zone reported in EC2 and other responses |
diff --git a/docs/configuration/partitions.md b/docs/configuration/partitions.md
new file mode 100644
index 0000000000..d1bcbe0afd
--- /dev/null
+++ b/docs/configuration/partitions.md
@@ -0,0 +1,91 @@
+# AWS Partitions
+
+Floci serves every AWS partition, not only the commercial one. A partition is the second
+segment of every ARN (`arn:aws-cn:...`), the DNS suffix of every endpoint
+(`amazonaws.com.cn`), and the set of services and regions AWS publishes there. Floci reads
+all of it from AWS's own partition metadata (botocore's `partitions.json` and
+`endpoints.json`, vendored as `aws/partitions.json` and refreshed with `make aws-data-sync`).
+
+| Partition | DNS suffix | Regions | Example |
+|---|---|---|---|
+| `aws` | `amazonaws.com` | 34 published (17 opt-in) | `us-east-1` |
+| `aws-cn` | `amazonaws.com.cn` | `cn-north-1`, `cn-northwest-1` | `cn-north-1` |
+| `aws-us-gov` | `amazonaws.com` | `us-gov-east-1`, `us-gov-west-1` | `us-gov-west-1` |
+| `aws-iso` | `c2s.ic.gov` | `us-iso-east-1`, `us-iso-west-1` | `us-iso-east-1` |
+| `aws-iso-b` | `sc2s.sgov.gov` | `us-isob-east-1`, `us-isob-west-1` | `us-isob-east-1` |
+| `aws-iso-e` | `cloud.adc-e.uk` | `eu-isoe-west-1` | `eu-isoe-west-1` |
+| `aws-iso-f` | `csp.hci.ic.gov` | `us-isof-east-1`, `us-isof-south-1` | `us-isof-south-1` |
+| `aws-eusc` | `amazonaws.eu` | `eusc-de-east-1` | `eusc-de-east-1` |
+
+## Which partition a deployment serves
+
+The deployment's partition is derived from `FLOCI_DEFAULT_REGION`: `cn-north-1` means
+`aws-cn`, `us-gov-west-1` means `aws-us-gov`, and so on. Set `FLOCI_PARTITIONS_ID`
+(`floci.partitions.id`) to name it explicitly; startup refuses a value that is not a
+published partition or that contradicts a recognised default region, and logs one line
+naming the partition it settled on:
+
+```
+Partition: aws-cn (default-region cn-north-1, dns suffix amazonaws.com.cn)
+```
+
+A default region the vendored data does not know only warns. AWS launches regions faster
+than the data is refreshed, and botocore's region-shape rules (`cn-*`, `us-gov-*`, ...)
+still place it; anything else falls back to `aws`, which is what the AWS SDKs do too.
+
+## Which partition a request belongs to
+
+Each request's partition comes from the region in its SigV4 credential scope, exactly as
+LocalStack and moto do it. A client signing `cn-north-1` is a China client even when Floci
+was started with `us-east-1`, so one process can serve several partitions at once. Requests
+without a credential, and background work (pollers, schedulers, startup hooks), use the
+deployment's partition.
+
+The scope region of a global service is its *signing* region, not a place to put regional
+resources: China IAM always signs `cn-north-1` even from Ningxia, GovCloud IAM signs
+`us-gov-west-1`. Floci uses it to pick the partition and nothing else. The
+`<partition>-global` pseudo-regions the SDKs accept (`aws-global`, `aws-cn-global`, ...)
+resolve to their partition as well; `aws-eusc` publishes none.
+
+## What changes per partition
+
+- **ARNs**: regional resources carry the partition of their region (`arn:aws-cn:sqs:cn-north-1:...`);
+ regionless resources (IAM, S3, STS, CloudFront, Route 53, Organizations) carry the request's
+ partition.
+- **DescribeRegions**: the request's partition's regions, with the partition's endpoints.
+ As on AWS, a commercial deployment lists the 17 regions that need no opt-in by default and
+ all 34 with `AllRegions=true`, where opt-in regions report `not-opted-in`.
+- **Hostname recognition**: every published region id, in every partition, is a region label
+ in an S3 virtual-host or execute-api hostname.
+
+## What does not change
+
+- **Service principals** are `<service>.amazonaws.com` in every partition; that is the rule
+ the AWS CDK applies today, and the older per-partition forms (`.amazonaws.com.cn`) are legacy.
+- **XML namespaces** and the S3 canned-ACL group URIs (`http://acs.amazonaws.com/groups/...`)
+ are identifiers, not hosts.
+- **AWS managed policy ARNs** keep the literal `aws` account slot: `arn:aws-cn:iam::aws:policy/AdministratorAccess`.
+
+## Partition-absent services
+
+AWS publishes which services exist in each partition (CloudFront is not in GovCloud, IAM is
+not in `aws-eusc`). On AWS a request for an absent service never reaches an API: the SDK
+fails to resolve the host. Floci serves every enabled service in every partition; a strict
+mode that mirrors the SDK failure is planned as an opt-in flag.
+
+## Open questions
+
+These values have no published source Floci can cite, so it does not guess them; they keep
+the commercial value or Floci's own base host until sourced:
+
+- the China CloudFront distribution domain suffix (only the API host is published);
+- the STS web-identity audience outside the commercial partition;
+- the Lambda function-URL host outside the commercial partition;
+- whether AWS managed policy documents differ in content in China or GovCloud;
+- the API Gateway regional hosted zone per region;
+- S3 `LocationConstraint` enum values and Route 53 hosted zones for the ISO and EUSC regions.
+
+## Related
+
+- [Environment Variables](environment-variables.md): `FLOCI_DEFAULT_REGION`, `FLOCI_PARTITIONS_ID`
+- [Multi-Account Isolation](multi-account.md): the account half of the credential scope
diff --git a/mkdocs.yml b/mkdocs.yml
index d0648313da..47972c1565 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -86,6 +86,7 @@ nav:
- Docker Configuration: configuration/docker.md
- Ports Reference: configuration/ports.md
- Multi-Account Isolation: configuration/multi-account.md
+ - AWS Partitions: configuration/partitions.md
- Storage Modes: configuration/storage.md
- TLS / HTTPS: configuration/tls.md
- Initialization Hooks: configuration/initialization-hooks.md
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index f74086f7f1..88b38c1149 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -64,6 +64,17 @@ public interface EmulatorConfig {
@WithDefault("000000000000")
String defaultAccountId();
+ PartitionsConfig partitions();
+
+ /**
+ * Which AWS partition the deployment serves. Normally derived from {@link #defaultRegion()}
+ * ({@code cn-north-1} means {@code aws-cn}); {@code id} pins it explicitly, and startup
+ * refuses a value that names no partition or contradicts the default region.
+ */
+ interface PartitionsConfig {
+ Optional<String> id();
+ }
+
/**
* Path to a shared mock-response configuration file used by the fixed-stub AI services
* (Textract, Comprehend, Rekognition) to return a caller-configured response instead of
diff --git a/src/main/java/io/github/hectorvent/floci/config/PartitionStartupValidator.java b/src/main/java/io/github/hectorvent/floci/config/PartitionStartupValidator.java
new file mode 100644
index 0000000000..b778348923
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/config/PartitionStartupValidator.java
@@ -0,0 +1,68 @@
+package io.github.hectorvent.floci.config;
+
+import io.github.hectorvent.floci.core.common.AwsPartition;
+import io.github.hectorvent.floci.core.common.AwsPartitions;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.quarkus.runtime.StartupEvent;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.event.Observes;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.util.Optional;
+
+/**
+ * Settles the deployment's partition at startup and refuses a configuration that contradicts
+ * itself. {@code floci.partitions.id} must name a published partition, and when
+ * {@code floci.default-region} is a region the vendored catalog can place, the two must agree:
+ * an operator who sets {@code FLOCI_DEFAULT_REGION=cn-north-1} with {@code FLOCI_PARTITIONS_ID=aws}
+ * would otherwise get China endpoints with commercial ARNs and never a message saying why.
+ *
+ * <p>A default region the catalog does not know is a warning, not an error: AWS launches
+ * regions faster than the vendored data is refreshed, and the {@code regionRegex} rules or the
+ * commercial fallback still place it somewhere. Startup rather than first use, so the one
+ * INFO line naming the partition is in every log.
+ */
+@ApplicationScoped
+public class PartitionStartupValidator {
+
+ private static final Logger LOG = Logger.getLogger(PartitionStartupValidator.class);
+
+ private final EmulatorConfig config;
+
+ @Inject
+ public PartitionStartupValidator(EmulatorConfig config) {
+ this.config = config;
+ }
+
+ void onStart(@Observes StartupEvent ignored) {
+ AwsPartition partition = validate(config.defaultRegion(), config.partitions().id());
+ LOG.infov("Partition: {0} (default-region {1}, dns suffix {2})",
+ partition.id(), config.defaultRegion(), partition.dnsSuffix());
+ }
+
+ /**
+ * The partition the deployment serves.
+ *
+ * @throws IllegalStateException when {@code configuredPartition} names no published partition,
+ * or disagrees with a default region the catalog recognises
+ */
+ static AwsPartition validate(String defaultRegion, Optional<String> configuredPartition) {
+ String effective = RegionResolver.effectivePartition(defaultRegion, configuredPartition);
+ AwsPartition partition = AwsPartitions.find(effective).orElseThrow(() -> new IllegalStateException(
+ "floci.partitions.id names no AWS partition: '" + effective + "'. Published partitions: "
+ + AwsPartitions.ids()));
+ Optional<AwsPartition> regionPartition = AwsPartitions.forRegion(defaultRegion);
+ if (regionPartition.isEmpty()) {
+ LOG.warnv("floci.default-region {0} is not a published AWS region in the vendored partition data; "
+ + "treating it as partition {1}. Run 'make aws-data-sync' if AWS has launched it since.",
+ defaultRegion, partition.id());
+ } else if (!regionPartition.get().id().equals(partition.id())) {
+ throw new IllegalStateException("floci.partitions.id is '" + partition.id()
+ + "' but floci.default-region " + defaultRegion + " belongs to partition '"
+ + regionPartition.get().id() + "'. Set both to the same partition, or unset "
+ + "floci.partitions.id to derive it from the region.");
+ }
+ return partition;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/config/TlsConfigSource.java b/src/main/java/io/github/hectorvent/floci/config/TlsConfigSource.java
index e0deb35efd..3008081c81 100644
--- a/src/main/java/io/github/hectorvent/floci/config/TlsConfigSource.java
+++ b/src/main/java/io/github/hectorvent/floci/config/TlsConfigSource.java
@@ -75,7 +75,7 @@ public class TlsConfigSource implements ConfigSource {
"*.execute-api.localhost.localstack.cloud",
"*.cloudfront.localhost.floci.io", "*.cloudfront.localhost",
"host.docker.internal"));
- for (String region : AwsRegions.ALL) {
+ for (String region : AwsRegions.KNOWN_IDS.stream().sorted().toList()) {
sans.add("*.dkr.ecr." + region + ".localhost.floci.io");
}
return List.copyOf(sans);
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AccountContextFilter.java b/src/main/java/io/github/hectorvent/floci/core/common/AccountContextFilter.java
index 6a439d3841..bf06347265 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AccountContextFilter.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AccountContextFilter.java
@@ -54,28 +54,38 @@ public class AccountContextFilter implements ContainerRequestFilter {
Object pinnedAccount = ctx.getProperty(PINNED_ACCOUNT_PROPERTY);
if (pinnedAccount != null) {
requestContext.setAccountId(pinnedAccount.toString());
- requestContext.setRegion(regionResolver.resolveRegionFromAuth(null));
+ applyRegion(regionResolver.resolveRegionFromAuth(null));
return;
}
String auth = ctx.getHeaderString("Authorization");
if (auth != null && !auth.isEmpty()) {
String akid = accountResolver.extractAccessKeyId(auth);
requestContext.setAccountId(resolveAccount(akid, accountResolver.resolve(auth)));
- requestContext.setRegion(regionResolver.resolveRegionFromAuth(auth));
+ applyRegion(regionResolver.resolveRegionFromAuth(auth));
} else {
String credential = ctx.getUriInfo().getQueryParameters().getFirst("X-Amz-Credential");
if (credential != null && !credential.isEmpty()) {
String akid = accountResolver.extractPresignedAccessKeyId(credential);
requestContext.setAccountId(
resolveAccount(akid, accountResolver.resolveFromPresignedCredential(credential)));
- requestContext.setRegion(regionResolver.resolveRegionFromPresignedCredential(credential));
+ applyRegion(regionResolver.resolveRegionFromPresignedCredential(credential));
} else {
requestContext.setAccountId(accountResolver.resolve(null));
- requestContext.setRegion(regionResolver.resolveRegionFromAuth(null));
+ applyRegion(regionResolver.resolveRegionFromAuth(null));
}
}
}
+ /**
+ * The region and its partition travel together: the SigV4 credential scope is the only
+ * place a request says which partition it belongs to (a China client signs {@code cn-north-1}
+ * even for IAM), so the partition is derived here, once, from the same value.
+ */
+ private void applyRegion(String region) {
+ requestContext.setRegion(region);
+ requestContext.setPartition(regionResolver.partitionForRegion(region));
+ }
+
/**
* Applies the account-resolution precedence. A 12-digit AKID is already reflected in
* {@code resolvedDefault} (the account or default returned by {@link AccountResolver});
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsArnUtils.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsArnUtils.java
index 4e33a9fd62..bab2a35be7 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsArnUtils.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsArnUtils.java
@@ -26,16 +26,26 @@ public final class AwsArnUtils {
* gets {@code aws-us-gov}, and everything else gets {@code aws}. See
* {@link AwsRegions#partitionFor}.
*
- * <p>Global services pass an empty region and therefore keep {@code aws}. That is a known
- * gap rather than a decision: an IAM ARN in a GovCloud deployment really is
- * {@code arn:aws-us-gov:iam::…}, but nothing in the region argument can say so. Those call
- * sites need a partition from the deployment, not from the resource, and they are left
- * alone until there is one.
+ * <p>Global services pass an empty region, and nothing in that argument can say which
+ * partition they belong to, so this keeps {@code aws} for them. A call site that knows the
+ * request's partition mints those through {@link #global} (or
+ * {@link RegionResolver#buildGlobalArn}); the fallback here stays only until every
+ * regionless call site has moved, after which a blank region becomes an error.
*/
public static Arn of(String service, String region, String accountId, String resource) {
return new Arn(AwsRegions.partitionFor(region), service, region, accountId, resource);
}
+ /**
+ * Factory for the ARN of a global service, which carries no region and whose partition
+ * is the caller's: {@code arn:<partition>:<service>::<accountId>:<resource>}. The
+ * partition is taken as given and never derived; a static utility must not reach into
+ * the request scope, or the same call would mint different ARNs depending on the thread.
+ */
+ public static Arn global(String partition, String service, String accountId, String resource) {
+ return new Arn(partition, service, "", accountId, resource);
+ }
+
@Override
public String toString() {
return "arn:" + partition + ":" + service + ":" + region + ":" + accountId + ":" + resource;
@@ -130,21 +140,17 @@ public final class AwsArnUtils {
}
/**
- * True when the ARN names a partition other than {@code aws}, the only one Floci emulates.
- * An empty partition field is not foreign: callers that omit it are naming a local
- * resource.
- *
- * <p>Deliberately a literal {@code aws} rather than {@link #PARTITION_REGEX}. That constant
- * exists to recognise a legal ARN in any partition; this asks the opposite question, whether
- * the ARN names a partition this emulator can serve, and the answer is only ever the
- * commercial one.
+ * True when the ARN names a partition other than {@code localPartition}, the one the current
+ * request belongs to ({@link RegionResolver#getPartition()}). An empty partition field is
+ * not foreign: callers that omit it are naming a local resource. Mirrors
+ * {@link #isForeignAccount}: foreign is relative to the caller, never to a fixed {@code aws}.
*/
- public static boolean isForeignPartition(Arn arn) {
+ public static boolean isForeignPartition(Arn arn, String localPartition) {
if (arn == null) {
return false;
}
String partition = arn.partition();
- return partition != null && !partition.isEmpty() && !"aws".equals(partition);
+ return partition != null && !partition.isEmpty() && !partition.equals(localPartition);
}
/**
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsPartition.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsPartition.java
new file mode 100644
index 0000000000..28a2c8c11e
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsPartition.java
@@ -0,0 +1,129 @@
+package io.github.hectorvent.floci.core.common;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * One AWS partition as AWS publishes it: {@code aws}, {@code aws-cn}, {@code aws-us-gov}, the
+ * classified {@code aws-iso*} family and {@code aws-eusc}. Every field is vendored from botocore's
+ * {@code partitions.json} and {@code endpoints.json} into {@code aws/partitions.json} by
+ * {@code tools/aws/regen_partitions.py}; nothing here is hand-typed. See {@link AwsPartitions}
+ * for the catalog and the region-to-partition lookup.
+ *
+ * @param id the partition id, the second segment of every ARN minted in it
+ * @param name AWS's display name ({@code AWS Standard}, {@code AWS China}, ...)
+ * @param dnsSuffix the suffix every regional endpoint is served under
+ * @param dualStackDnsSuffix the suffix of the dual-stack endpoints
+ * @param implicitGlobalRegion the region global services sign with when a client names none
+ * @param regionRegex botocore's shape of a region id in this partition, for regions
+ * launched after the vendored data was generated
+ * @param globalPseudoRegion the {@code <partition>-global} label the SDKs accept as a region,
+ * or {@code null} where the partition has none ({@code aws-eusc})
+ * @param regions the published regions, in botocore order
+ * @param services every service key {@code endpoints.json} lists for the partition
+ * @param globalServices services with a partition-wide endpoint, by service key
+ * @param supportsDualStack whether the partition publishes dual-stack endpoints
+ * @param supportsFips whether the partition publishes FIPS endpoints
+ */
+public record AwsPartition(
+ String id,
+ String name,
+ String dnsSuffix,
+ String dualStackDnsSuffix,
+ String implicitGlobalRegion,
+ Pattern regionRegex,
+ String globalPseudoRegion,
+ List<Region> regions,
+ Set<String> services,
+ Map<String, GlobalEndpoint> globalServices,
+ boolean supportsDualStack,
+ boolean supportsFips) {
+
+ /**
+ * A published region.
+ *
+ * @param id the region id
+ * @param description AWS's display name, e.g. {@code US East (N. Virginia)}
+ * @param optIn true when an account must enable the region before using it, so
+ * DescribeRegions omits it unless {@code AllRegions} is set
+ * @param s3WebsiteDashForm true when the S3 website endpoint is the legacy
+ * {@code s3-website-<region>} form rather than {@code s3-website.<region>}
+ */
+ public record Region(String id, String description, boolean optIn, boolean s3WebsiteDashForm) {
+ }
+
+ /**
+ * A partition-wide service endpoint, e.g. IAM in {@code aws} at {@code iam.amazonaws.com}
+ * signed with {@code us-east-1}. The signing region is the credential-scope region such a
+ * client sends; it says which partition the request belongs to and nothing about which
+ * region a regional resource should land in.
+ *
+ * @param regionalized true when the service also has per-region endpoints and the global
+ * host is used only for a client that names no region (STS, S3)
+ */
+ public record GlobalEndpoint(String hostname, String signingRegion, boolean regionalized) {
+ }
+
+ public AwsPartition {
+ regions = List.copyOf(regions);
+ services = Set.copyOf(services);
+ globalServices = Map.copyOf(globalServices);
+ }
+
+ /** True when {@code endpoints.json} lists {@code service} for this partition. */
+ public boolean offers(String service) {
+ return service != null && services.contains(service);
+ }
+
+ public Optional<GlobalEndpoint> globalEndpoint(String service) {
+ return Optional.ofNullable(service == null ? null : globalServices.get(service));
+ }
+
+ /**
+ * True only for the commercial partition: STS is regionalized everywhere, and the global
+ * {@code sts.amazonaws.com} host exists in {@code aws} alone.
+ */
+ public boolean hasGlobalSts() {
+ return globalServices.containsKey("sts");
+ }
+
+ public Optional<String> pseudoRegion() {
+ return Optional.ofNullable(globalPseudoRegion);
+ }
+
+ /** True when {@code label} is this partition's {@code <partition>-global} pseudo-region. */
+ public boolean isPseudoRegion(String label) {
+ return globalPseudoRegion != null && label != null
+ && globalPseudoRegion.equals(label.trim().toLowerCase(Locale.ROOT));
+ }
+
+ public List<String> regionIds() {
+ return regions.stream().map(Region::id).toList();
+ }
+
+ public Optional<Region> region(String id) {
+ if (id == null) {
+ return Optional.empty();
+ }
+ String normalized = id.trim().toLowerCase(Locale.ROOT);
+ return regions.stream().filter(region -> region.id().equals(normalized)).findFirst();
+ }
+
+ public boolean isPublishedRegion(String id) {
+ return region(id).isPresent();
+ }
+
+ /** True when {@code id} has the shape botocore gives this partition's regions. */
+ public boolean matchesRegionRegex(String id) {
+ return id != null && regionRegex.matcher(id.trim().toLowerCase(Locale.ROOT)).matches();
+ }
+
+ /** The regional endpoint host, {@code <service>.<region>.<dnsSuffix>}. */
+ public String regionalHostname(String service, String region) {
+ return service + "." + region + "." + dnsSuffix;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsPartitions.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsPartitions.java
new file mode 100644
index 0000000000..3ca186230f
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsPartitions.java
@@ -0,0 +1,264 @@
+package io.github.hectorvent.floci.core.common;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * The catalog of every AWS partition, read once from the vendored {@code aws/partitions.json}.
+ * The file is generated from botocore's own partition metadata (MIT-licensed, published at
+ * https://github.com/boto/botocore/tree/develop/botocore/data) by
+ * {@code tools/aws/regen_partitions.py}, and {@code make aws-data-check} keeps it in sync.
+ *
+ * <p>A region resolves to its partition in three steps, strictest first: an exact match on a
+ * {@code <partition>-global} pseudo-region, membership in a partition's published region list,
+ * then botocore's {@code regionRegex}, which classifies a region launched after the vendored
+ * data was generated. {@link #forRegion} is the strict form and answers {@code Optional.empty()}
+ * for anything else; {@link #forRegionOrCommercial} is the fail-open form ARN minting uses,
+ * because the AWS SDKs themselves put an unknown region in {@code aws}.
+ *
+ * <p>A missing or malformed resource is a build defect, not a runtime condition, so loading
+ * fails with {@link IllegalStateException} rather than degrading to a commercial-only catalog.
+ */
+public final class AwsPartitions {
+
+ static final String RESOURCE_NAME = "aws/partitions.json";
+ static final String COMMERCIAL_ID = "aws";
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ record Catalog(List<AwsPartition> partitions,
+ Map<String, AwsPartition> byId,
+ Map<String, AwsPartition> byRegion,
+ Map<String, AwsPartition> byPseudoRegion,
+ Set<String> regionIds,
+ List<String> dnsSuffixesLongestFirst) {
+ }
+
+ private static final class Holder {
+ static final Catalog CATALOG = load();
+ }
+
+ /** The suffix and the host label(s) before it, from {@link #stripKnownDnsSuffix}. */
+ public record DnsSuffixMatch(String prefix, String dnsSuffix) {
+ }
+
+ private AwsPartitions() {
+ }
+
+ public static List<AwsPartition> all() {
+ return Holder.CATALOG.partitions();
+ }
+
+ public static AwsPartition commercial() {
+ return byId(COMMERCIAL_ID);
+ }
+
+ public static Optional<AwsPartition> find(String id) {
+ if (id == null) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(Holder.CATALOG.byId().get(id.trim().toLowerCase(Locale.ROOT)));
+ }
+
+ /** @throws IllegalArgumentException when {@code id} names no published partition */
+ public static AwsPartition byId(String id) {
+ return find(id).orElseThrow(() -> new IllegalArgumentException("Unknown AWS partition: " + id));
+ }
+
+ public static Set<String> ids() {
+ return Holder.CATALOG.byId().keySet();
+ }
+
+ /**
+ * The partition {@code region} belongs to, or empty for null, blank and unrecognised
+ * labels. A {@code <partition>-global} pseudo-region resolves to its partition.
+ */
+ public static Optional<AwsPartition> forRegion(String region) {
+ String normalized = normalize(region);
+ if (normalized == null) {
+ return Optional.empty();
+ }
+ Catalog catalog = Holder.CATALOG;
+ AwsPartition byPseudoRegion = catalog.byPseudoRegion().get(normalized);
+ if (byPseudoRegion != null) {
+ return Optional.of(byPseudoRegion);
+ }
+ AwsPartition byRegion = catalog.byRegion().get(normalized);
+ if (byRegion != null) {
+ return Optional.of(byRegion);
+ }
+ return catalog.partitions().stream()
+ .filter(partition -> partition.matchesRegionRegex(normalized))
+ .findFirst();
+ }
+
+ /**
+ * {@link #forRegion}, falling back to the commercial partition. This is the AWS SDKs'
+ * behaviour for an unrecognised region and what ARN minting relies on so a region AWS
+ * launches tomorrow keeps working.
+ */
+ public static AwsPartition forRegionOrCommercial(String region) {
+ return forRegion(region).orElseGet(AwsPartitions::commercial);
+ }
+
+ /** True when {@code region} is in some partition's published list (pseudo-regions excluded). */
+ public static boolean isPublishedRegion(String region) {
+ String normalized = normalize(region);
+ return normalized != null && Holder.CATALOG.regionIds().contains(normalized);
+ }
+
+ /** Every published region id across all partitions. */
+ public static Set<String> allRegionIds() {
+ return Holder.CATALOG.regionIds();
+ }
+
+ /**
+ * {@code label} with a {@code <partition>-global} pseudo-region replaced by that partition's
+ * implicit global region ({@code aws-cn-global} becomes {@code cn-north-1}); any other label
+ * is returned trimmed and lower-cased, and null stays null.
+ */
+ public static String normalizeRegion(String label) {
+ String normalized = normalize(label);
+ if (normalized == null) {
+ return label;
+ }
+ AwsPartition partition = Holder.CATALOG.byPseudoRegion().get(normalized);
+ return partition == null ? normalized : partition.implicitGlobalRegion();
+ }
+
+ /**
+ * Splits {@code host} at the longest published DNS suffix it ends with, so
+ * {@code bucket.s3.cn-north-1.amazonaws.com.cn} yields the {@code amazonaws.com.cn} suffix
+ * rather than {@code amazonaws.com} with a dangling {@code .cn}. Case-insensitive; a port is
+ * not tolerated. Empty when {@code host} ends with no published suffix, or is nothing but one.
+ */
+ public static Optional<DnsSuffixMatch> stripKnownDnsSuffix(String host) {
+ if (host == null || host.isBlank()) {
+ return Optional.empty();
+ }
+ String lower = host.trim().toLowerCase(Locale.ROOT);
+ for (String suffix : Holder.CATALOG.dnsSuffixesLongestFirst()) {
+ if (lower.endsWith("." + suffix)) {
+ return Optional.of(new DnsSuffixMatch(lower.substring(0, lower.length() - suffix.length() - 1), suffix));
+ }
+ }
+ return Optional.empty();
+ }
+
+ private static String normalize(String label) {
+ if (label == null || label.isBlank()) {
+ return null;
+ }
+ return label.trim().toLowerCase(Locale.ROOT);
+ }
+
+ private static Catalog load() {
+ try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(RESOURCE_NAME)) {
+ if (in == null) {
+ throw new IllegalStateException("Partition catalog resource not found: " + RESOURCE_NAME);
+ }
+ return parse(in);
+ } catch (IOException e) {
+ throw new IllegalStateException("Failed to read the partition catalog " + RESOURCE_NAME, e);
+ }
+ }
+
+ static Catalog parse(InputStream in) throws IOException {
+ JsonNode root = MAPPER.readTree(in);
+ JsonNode partitionsNode = root.path("partitions");
+ if (!partitionsNode.isArray() || partitionsNode.isEmpty()) {
+ throw new IllegalStateException(RESOURCE_NAME + " has no partitions array");
+ }
+ List<AwsPartition> partitions = new ArrayList<>();
+ Map<String, AwsPartition> byId = new LinkedHashMap<>();
+ Map<String, AwsPartition> byRegion = new LinkedHashMap<>();
+ Map<String, AwsPartition> byPseudoRegion = new LinkedHashMap<>();
+ Set<String> regionIds = new LinkedHashSet<>();
+ Set<String> dnsSuffixes = new LinkedHashSet<>();
+ for (JsonNode node : partitionsNode) {
+ AwsPartition partition = parsePartition(node);
+ if (byId.put(partition.id(), partition) != null) {
+ throw new IllegalStateException(RESOURCE_NAME + " lists partition " + partition.id() + " twice");
+ }
+ partitions.add(partition);
+ for (AwsPartition.Region region : partition.regions()) {
+ if (byRegion.put(region.id(), partition) != null) {
+ throw new IllegalStateException(RESOURCE_NAME + " lists region " + region.id() + " twice");
+ }
+ regionIds.add(region.id());
+ }
+ if (partition.globalPseudoRegion() != null) {
+ byPseudoRegion.put(partition.globalPseudoRegion(), partition);
+ }
+ dnsSuffixes.add(partition.dnsSuffix());
+ dnsSuffixes.add(partition.dualStackDnsSuffix());
+ }
+ if (!byId.containsKey(COMMERCIAL_ID)) {
+ throw new IllegalStateException(RESOURCE_NAME + " lacks the commercial partition");
+ }
+ List<String> suffixesLongestFirst = new ArrayList<>(dnsSuffixes);
+ suffixesLongestFirst.sort(Comparator.comparingInt(String::length).reversed().thenComparing(Comparator.naturalOrder()));
+ return new Catalog(List.copyOf(partitions), Map.copyOf(byId), Map.copyOf(byRegion),
+ Map.copyOf(byPseudoRegion), Set.copyOf(regionIds), List.copyOf(suffixesLongestFirst));
+ }
+
+ private static AwsPartition parsePartition(JsonNode node) {
+ String id = required(node, "id");
+ List<AwsPartition.Region> regions = new ArrayList<>();
+ for (JsonNode regionNode : node.path("regions")) {
+ regions.add(new AwsPartition.Region(
+ required(regionNode, "id"),
+ regionNode.path("description").asText(""),
+ regionNode.path("optIn").asBoolean(false),
+ regionNode.path("s3WebsiteDashForm").asBoolean(false)));
+ }
+ Set<String> services = new LinkedHashSet<>();
+ for (JsonNode service : node.path("services")) {
+ services.add(service.asText());
+ }
+ Map<String, AwsPartition.GlobalEndpoint> globalServices = new LinkedHashMap<>();
+ JsonNode globalNode = node.path("globalServices");
+ globalNode.fieldNames().forEachRemaining(service -> {
+ JsonNode endpoint = globalNode.get(service);
+ globalServices.put(service, new AwsPartition.GlobalEndpoint(
+ required(endpoint, "hostname"),
+ required(endpoint, "signingRegion"),
+ endpoint.path("regionalized").asBoolean(false)));
+ });
+ JsonNode pseudo = node.get("globalPseudoRegion");
+ return new AwsPartition(
+ id,
+ required(node, "name"),
+ required(node, "dnsSuffix"),
+ required(node, "dualStackDnsSuffix"),
+ required(node, "implicitGlobalRegion"),
+ Pattern.compile(required(node, "regionRegex")),
+ pseudo == null || pseudo.isNull() ? null : pseudo.asText(),
+ regions,
+ services,
+ globalServices,
+ node.path("supportsDualStack").asBoolean(false),
+ node.path("supportsFips").asBoolean(false));
+ }
+
+ private static String required(JsonNode node, String field) {
+ JsonNode value = node.get(field);
+ if (value == null || value.isNull() || value.asText().isBlank()) {
+ throw new IllegalStateException(RESOURCE_NAME + ": missing " + field + " in " + node);
+ }
+ return value.asText();
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsRegions.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsRegions.java
index 5f5cf5a345..afdade1f83 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsRegions.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsRegions.java
@@ -1,105 +1,72 @@
package io.github.hectorvent.floci.core.common;
import java.util.List;
-import java.util.Locale;
import java.util.Set;
-import java.util.regex.Pattern;
/**
- * Catalog of AWS regions the emulator advertises. Single source of truth for
- * every feature that enumerates regions (EC2 DescribeRegions, EKS ECR-mirror
- * hostnames, ...).
+ * Region facade over the vendored partition catalog ({@link AwsPartitions}). Single source of
+ * truth for every feature that enumerates or classifies regions: EC2 DescribeRegions, the ECR
+ * mirror hostnames EKS nodes get, TLS certificate SANs, hostname parsing, and the partition
+ * segment of every ARN.
*/
public final class AwsRegions {
- public static final List<String> ALL = List.of(
- "us-east-1", "us-east-2", "us-west-1", "us-west-2",
- "eu-west-1", "eu-west-2", "eu-west-3", "eu-central-1",
- "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2",
- "ap-south-1", "sa-east-1", "ca-central-1");
+ /**
+ * The commercial partition's published regions, in botocore order. Callers that serve one
+ * request should prefer {@link #advertised(String)} with the request's partition; this list
+ * is what static, deployment-wide consumers (certificate SANs) enumerate.
+ */
+ public static final List<String> ALL = advertised(AwsPartitions.COMMERCIAL_ID);
/**
- * Every published AWS region id, across the commercial, GovCloud and China partitions.
+ * Every published AWS region id, across all partitions.
*
* <p>Distinct from {@link #ALL}, and deliberately a superset of it. {@code ALL} is what
- * this emulator <em>advertises</em> — what DescribeRegions returns. {@code KNOWN_IDS} is
- * for <em>recognising</em> a region id that a client wrote, most importantly inside a
- * hostname, where the alternative is a shape like {@code [a-z]{2}-[a-z-]+-\d+} that also
- * matches perfectly ordinary strings ({@code my-cd-1}, {@code eu-team-2}).
+ * this emulator <em>advertises</em> in the commercial partition. {@code KNOWN_IDS} is for
+ * <em>recognising</em> a region id that a client wrote, most importantly inside a hostname,
+ * where the alternative is a shape like {@code [a-z]{2}-[a-z-]+-\d+} that also matches
+ * perfectly ordinary strings ({@code my-cd-1}, {@code eu-team-2}).
*
- * <p>Sourced from the AWS General Reference endpoint tables. It needs an entry when AWS
- * launches a region; the cost of a missing one is documented at each call site, because it
- * differs per caller.
+ * <p>It follows botocore's published lists ({@code make aws-data-sync}); the cost of a
+ * region newer than the vendored data is documented at each call site, because it differs
+ * per caller.
*/
- public static final Set<String> KNOWN_IDS = Set.of(
- "us-east-1", "us-east-2", "us-west-1", "us-west-2",
- "af-south-1",
- "ap-east-1", "ap-east-2",
- "ap-south-1", "ap-south-2",
- "ap-northeast-1", "ap-northeast-2", "ap-northeast-3",
- "ap-southeast-1", "ap-southeast-2", "ap-southeast-3", "ap-southeast-4",
- "ap-southeast-5", "ap-southeast-6", "ap-southeast-7",
- "ca-central-1", "ca-west-1",
- "eu-central-1", "eu-central-2",
- "eu-west-1", "eu-west-2", "eu-west-3",
- "eu-north-1", "eu-south-1", "eu-south-2",
- "il-central-1",
- "me-central-1", "me-south-1",
- "mx-central-1",
- "sa-east-1",
- "us-gov-east-1", "us-gov-west-1",
- "cn-north-1", "cn-northwest-1");
+ public static final Set<String> KNOWN_IDS = AwsPartitions.allRegionIds();
- /** True when {@code label} is exactly an AWS region id, case-insensitively. */
- public static boolean isRegionId(String label) {
- return label != null && KNOWN_IDS.contains(label.toLowerCase(Locale.ROOT));
- }
-
- /** The partition every region falls back to: the commercial one. */
- public static final String DEFAULT_PARTITION = "aws";
+ /** The partition every unrecognised region falls back to: the commercial one. */
+ public static final String DEFAULT_PARTITION = AwsPartitions.COMMERCIAL_ID;
/** The DNS suffix of the commercial partition, shared with {@code aws-us-gov}. */
public static final String DEFAULT_DNS_SUFFIX = "amazonaws.com";
- private record PartitionRule(Pattern regionPattern, String partition, String dnsSuffix) {
- }
-
/**
- * Region-to-partition rules, transcribed from the AWS SDKs' own public partition metadata
- * (botocore's {@code partitions.json}, MIT-licensed and openly published at
- * https://github.com/boto/botocore/blob/develop/botocore/data/partitions.json). The patterns
- * are that file's {@code regionRegex} values verbatim, so they stay comparable against it.
+ * The regions a partition publishes, in botocore order, e.g. the 34 commercial regions for
+ * {@code aws} or {@code cn-north-1} and {@code cn-northwest-1} for {@code aws-cn}.
*
- * <p>Only the non-commercial partitions need a rule: the commercial {@code aws} partition is
- * the fallback, and {@code aws-us-gov} shares its DNS suffix, which is why GovCloud carries a
- * rule for the partition id alone. The rules are mutually exclusive by construction (nothing
- * matching {@code us-gov-*}, {@code us-iso-*} or {@code us-isob-*} matches the commercial
- * shape, because {@code \w} does not cross a hyphen), so evaluation order is not load-bearing.
- *
- * <p>An unrecognised region resolves to {@code aws}. That is what the SDKs themselves do, and
- * it keeps a region AWS launches tomorrow working rather than failing closed.
+ * @throws IllegalArgumentException when {@code partitionId} names no published partition
*/
- private static final List<PartitionRule> PARTITION_RULES = List.of(
- new PartitionRule(Pattern.compile("^cn-\\w+-\\d+$"), "aws-cn", "amazonaws.com.cn"),
- new PartitionRule(Pattern.compile("^us-gov-\\w+-\\d+$"), "aws-us-gov", DEFAULT_DNS_SUFFIX),
- new PartitionRule(Pattern.compile("^us-iso-\\w+-\\d+$"), "aws-iso", "c2s.ic.gov"),
- new PartitionRule(Pattern.compile("^us-isob-\\w+-\\d+$"), "aws-iso-b", "sc2s.sgov.gov"),
- new PartitionRule(Pattern.compile("^eu-isoe-\\w+-\\d+$"), "aws-iso-e", "cloud.adc-e.uk"),
- new PartitionRule(Pattern.compile("^us-isof-\\w+-\\d+$"), "aws-iso-f", "csp.hci.ic.gov"),
- new PartitionRule(Pattern.compile("^eusc-de-\\w+-\\d+$"), "aws-eusc", "amazonaws.eu"));
+ public static List<String> advertised(String partitionId) {
+ return AwsPartitions.byId(partitionId).regionIds();
+ }
+
+ /** True when {@code label} is exactly a published AWS region id, case-insensitively. */
+ public static boolean isRegionId(String label) {
+ return AwsPartitions.isPublishedRegion(label);
+ }
/**
* The partition id a region belongs to: {@code aws}, {@code aws-us-gov}, {@code aws-cn}, or
* one of the classified partitions. This is the second segment of every ARN minted for a
- * resource in that region.
+ * resource in that region. A {@code <partition>-global} pseudo-region resolves to its
+ * partition.
*
- * <p>A null, blank or unrecognised region gives {@code aws}. Blank is not an error case: many
- * ARNs are global and carry no region at all ({@code arn:aws:iam::…}), and those keep the
- * commercial partition because the resource's own region cannot say otherwise.
+ * <p>A null, blank or unrecognised region gives {@code aws}, which is what the AWS SDKs do
+ * with a region they do not know. Blank is the common case for a global-service ARN
+ * ({@code arn:aws:iam::…}); callers that know the deployment's partition should mint those
+ * through {@link RegionResolver#buildGlobalArn} instead of relying on this fallback.
*/
public static String partitionFor(String region) {
- PartitionRule rule = ruleFor(region);
- return rule == null ? DEFAULT_PARTITION : rule.partition();
+ return AwsPartitions.forRegionOrCommercial(region).id();
}
/**
@@ -108,21 +75,7 @@ public final class AwsRegions {
* {@link #partitionFor}.
*/
public static String dnsSuffixFor(String region) {
- PartitionRule rule = ruleFor(region);
- return rule == null ? DEFAULT_DNS_SUFFIX : rule.dnsSuffix();
- }
-
- private static PartitionRule ruleFor(String region) {
- if (region == null || region.isBlank()) {
- return null;
- }
- String normalized = region.trim().toLowerCase(Locale.ROOT);
- for (PartitionRule rule : PARTITION_RULES) {
- if (rule.regionPattern().matcher(normalized).matches()) {
- return rule;
- }
- }
- return null;
+ return AwsPartitions.forRegionOrCommercial(region).dnsSuffix();
}
private AwsRegions() {
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/RegionResolver.java b/src/main/java/io/github/hectorvent/floci/core/common/RegionResolver.java
index 6e43af617e..003b8b9059 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/RegionResolver.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/RegionResolver.java
@@ -7,9 +7,21 @@ import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.HttpHeaders;
+import java.util.Locale;
+import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Resolves the region, account and partition a request runs under, and mints ARNs for them.
+ *
+ * <p>The deployment's partition is derived from {@code floci.default-region} unless
+ * {@code floci.partitions.id} names it explicitly ({@link PartitionStartupValidator} checks the
+ * two agree). Each request's partition comes from its SigV4 signing region: a request signed
+ * with {@code cn-north-1} belongs to {@code aws-cn} whatever the deployment default, so one
+ * process can serve several partitions. Requests with no credential, and work outside a request
+ * scope (pollers, startup), get the deployment's partition.
+ */
@ApplicationScoped
public class RegionResolver {
@@ -20,16 +32,18 @@ public class RegionResolver {
// Matches ONLY a real AWS region label immediately after ".execute-api.", e.g.
// abc123.execute-api.ap-northeast-2.localhost:4566 -> "ap-northeast-2"
// abc123.execute-api.us-east-1.amazonaws.com -> "us-east-1"
- // A region id is {geo}-{direction(s)}-{number} (us-east-1, ap-northeast-2, us-gov-east-1).
+ // A region id is {geo}-{direction(s)}-{number} (us-east-1, ap-northeast-2, us-gov-east-1,
+ // eusc-de-east-1), and the label is then checked against the published region ids.
// This deliberately does NOT match Floci's built-in execute-api DNS suffixes
// (…execute-api.localhost, …execute-api.localhost.floci.io, …execute-api.localhost.localstack.cloud):
// those carry no region label, so the older `[a-zA-Z0-9-]+` pattern mis-parsed "localhost"
// as the region and broke the region-scoped API lookup. Case-insensitive per DNS.
private static final Pattern HOST_REGION_PATTERN =
- Pattern.compile("\\.execute-api\\.([a-z]{2}-[a-z-]+-\\d+)\\.", Pattern.CASE_INSENSITIVE);
+ Pattern.compile("\\.execute-api\\.([a-z]{2,4}-[a-z-]+-\\d+)\\.", Pattern.CASE_INSENSITIVE);
private final String defaultRegion;
private final String defaultAccountId;
+ private final String defaultPartition;
// Field-injected so the two-arg constructor used in tests remains valid.
@Inject
@@ -37,12 +51,32 @@ public class RegionResolver {
@Inject
public RegionResolver(EmulatorConfig config) {
- this(config.defaultRegion(), config.defaultAccountId());
+ this(config.defaultRegion(), config.defaultAccountId(),
+ effectivePartition(config.defaultRegion(), config.partitions().id()));
}
+ /** Derives the deployment partition from the default region. */
public RegionResolver(String defaultRegion, String defaultAccountId) {
+ this(defaultRegion, defaultAccountId, AwsRegions.partitionFor(defaultRegion));
+ }
+
+ public RegionResolver(String defaultRegion, String defaultAccountId, String defaultPartition) {
this.defaultRegion = defaultRegion;
this.defaultAccountId = defaultAccountId;
+ this.defaultPartition = defaultPartition;
+ }
+
+ /**
+ * The partition a deployment serves: {@code floci.partitions.id} when set, otherwise the
+ * partition of {@code floci.default-region} (fail-open to {@code aws} for a region the
+ * vendored data does not know, which {@link PartitionStartupValidator} warns about).
+ */
+ public static String effectivePartition(String defaultRegion, Optional<String> configuredPartition) {
+ return configuredPartition
+ .map(String::trim)
+ .filter(id -> !id.isEmpty())
+ .map(id -> id.toLowerCase(Locale.ROOT))
+ .orElseGet(() -> AwsRegions.partitionFor(defaultRegion));
}
public String resolveRegion(HttpHeaders headers) {
@@ -109,9 +143,13 @@ public class RegionResolver {
return null;
}
Matcher matcher = HOST_REGION_PATTERN.matcher(host);
+ if (!matcher.find()) {
+ return null;
+ }
// Region ids are lowercase (as are the region-scoped API store keys); normalize an
// uppercase host label like US-EAST-1 so the lookup does not 403 on a casing mismatch.
- return matcher.find() ? matcher.group(1).toLowerCase(java.util.Locale.ROOT) : null;
+ String label = matcher.group(1).toLowerCase(Locale.ROOT);
+ return AwsRegions.isRegionId(label) ? label : null;
}
public String getDefaultRegion() {
@@ -122,6 +160,43 @@ public class RegionResolver {
return defaultAccountId;
}
+ public String getDefaultPartition() {
+ return defaultPartition;
+ }
+
+ /**
+ * The partition a region belongs to, for the purpose of scoping a request. A blank region
+ * (no credential) is the deployment's own partition, not {@code aws}; a
+ * {@code <partition>-global} pseudo-region resolves to its partition; a region the catalog
+ * cannot place also falls back to the deployment's partition, because a request that
+ * reaches this emulator with an unknown region is far more likely a new local region than
+ * a foreign one.
+ */
+ public String partitionForRegion(String region) {
+ if (region == null || region.isBlank()) {
+ return defaultPartition;
+ }
+ return AwsPartitions.forRegion(region).map(AwsPartition::id).orElse(defaultPartition);
+ }
+
+ /**
+ * The partition of the current request when called from a request context, or the
+ * deployment's partition otherwise (async workers, startup, tests).
+ */
+ public String getPartition() {
+ if (requestContextInstance != null) {
+ try {
+ String partition = requestContextInstance.get().getPartition();
+ if (partition != null) {
+ return partition;
+ }
+ } catch (ContextNotActiveException ignored) {
+ // outside request scope: fall through to the deployment partition
+ }
+ }
+ return defaultPartition;
+ }
+
/**
* Returns the region for the current request when called from a request context,
* or the configured default region otherwise (async workers, startup, tests).
@@ -158,7 +233,24 @@ public class RegionResolver {
return defaultAccountId;
}
+ /**
+ * Mints a regional ARN, deriving the partition from {@code region}. A blank region means a
+ * global service, whose partition is the request's rather than something the region can
+ * say, so it routes to {@link #buildGlobalArn(String, String)}.
+ */
public String buildArn(String service, String region, String resource) {
+ if (region == null || region.isBlank()) {
+ return buildGlobalArn(service, resource);
+ }
return AwsArnUtils.Arn.of(service, region, getAccountId(), resource).toString();
}
+
+ /** Mints a regionless ARN ({@code arn:<partition>:iam::<account>:...}) in the request's partition. */
+ public String buildGlobalArn(String service, String resource) {
+ return buildGlobalArn(service, getAccountId(), resource);
+ }
+
+ public String buildGlobalArn(String service, String accountId, String resource) {
+ return AwsArnUtils.Arn.global(getPartition(), service, accountId, resource).toString();
+ }
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/RequestContext.java b/src/main/java/io/github/hectorvent/floci/core/common/RequestContext.java
index 3ec09e735b..d93d390927 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/RequestContext.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/RequestContext.java
@@ -3,7 +3,7 @@ package io.github.hectorvent.floci.core.common;
import jakarta.enterprise.context.RequestScoped;
/**
- * Holds per-request derived values — account ID and region — extracted from the
+ * Holds per-request derived values, account ID, region and partition, extracted from the
* incoming AWS credential and Authorization header. Populated by
* {@link AccountContextFilter} before any handler runs.
*/
@@ -12,6 +12,7 @@ public class RequestContext {
private String accountId;
private String region;
+ private String partition;
public String getAccountId() {
return accountId;
@@ -28,4 +29,17 @@ public class RequestContext {
public void setRegion(String region) {
this.region = region;
}
+
+ /**
+ * The partition the request's signing region belongs to ({@code aws}, {@code aws-cn}, ...),
+ * or null when nothing set it, in which case {@link RegionResolver#getPartition()} answers
+ * with the deployment's partition.
+ */
+ public String getPartition() {
+ return partition;
+ }
+
+ public void setPartition(String partition) {
+ this.partition = partition;
+ }
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java
index 58de4c4050..986cb5c0de 100644
--- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java
@@ -3,6 +3,8 @@ package io.github.hectorvent.floci.services.ec2;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.AwsNamespaces;
+import io.github.hectorvent.floci.core.common.AwsPartition;
+import io.github.hectorvent.floci.core.common.AwsPartitions;
import io.github.hectorvent.floci.core.common.XmlBuilder;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.ec2.model.*;
@@ -4075,16 +4077,21 @@ public class Ec2QueryHandler {
}
private Response handleDescribeRegions(MultivaluedMap<String, String> p, String region) {
- List<String> regions = service.describeRegions();
+ AwsPartition partition = AwsPartitions.forRegionOrCommercial(region);
+ boolean allRegions = Boolean.parseBoolean(p.getFirst("AllRegions"));
+ Set<String> requested = new HashSet<>(getList(p, "RegionName"));
XmlBuilder xml = new XmlBuilder()
.start("DescribeRegionsResponse", AwsNamespaces.EC2)
.elem("requestId", UUID.randomUUID().toString())
.start("regionInfo");
- for (String r : regions) {
+ for (AwsPartition.Region r : service.describeRegions(partition, allRegions || !requested.isEmpty())) {
+ if (!requested.isEmpty() && !requested.contains(r.id())) {
+ continue;
+ }
xml.start("item")
- .elem("regionName", r)
- .elem("regionEndpoint", "ec2." + r + ".amazonaws.com")
- .elem("optInStatus", "opt-in-not-required")
+ .elem("regionName", r.id())
+ .elem("regionEndpoint", partition.regionalHostname("ec2", r.id()))
+ .elem("optInStatus", r.optIn() ? "not-opted-in" : "opt-in-not-required")
.end("item");
}
xml.end("regionInfo").end("DescribeRegionsResponse");
diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java
index e177267478..5eae232c39 100644
--- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java
+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java
@@ -36,6 +36,7 @@ import io.github.hectorvent.floci.core.common.RequestContext;
import io.github.hectorvent.floci.core.common.RequestScopes;
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.AwsRegions;
import io.github.hectorvent.floci.core.common.CidrCanonicalizer;
import io.github.hectorvent.floci.core.common.ContainerTeardown;
@@ -7836,8 +7837,16 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {
return zones;
}
- public List<String> describeRegions() {
- return AwsRegions.ALL;
+ /**
+ * The regions DescribeRegions lists for {@code partition}: the enabled ones by default, which
+ * on AWS means every region that needs no opt-in, or all published regions with
+ * {@code AllRegions}. Nothing in this emulator opts a region in, so the opt-in ones only ever
+ * report {@code not-opted-in}.
+ */
+ public List<AwsPartition.Region> describeRegions(AwsPartition partition, boolean allRegions) {
+ return partition.regions().stream()
+ .filter(region -> allRegions || !region.optIn())
+ .toList();
}
public Map<String, String> describeAccountAttributes(String region) {
diff --git a/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java b/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java
index c5fb51f5fb..3096487586 100644
--- a/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java
+++ b/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java
@@ -1402,7 +1402,7 @@ public class EksClusterManager implements ClusterNodeInstanceProvider {
clusterName, e.getMessage());
return;
}
- List<String> regions = new ArrayList<>(AwsRegions.ALL);
+ List<String> regions = new ArrayList<>(AwsRegions.advertised(AwsRegions.partitionFor(config.defaultRegion())));
if (!regions.contains(config.defaultRegion())) {
regions.add(config.defaultRegion());
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaLayerService.java b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaLayerService.java
index dcf9767905..153ddaeba7 100644
--- a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaLayerService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaLayerService.java
@@ -455,9 +455,9 @@ public class LambdaLayerService {
+ " constraint: Member must satisfy regular expression pattern: "
+ LAYER_VERSION_ARN_PATTERN, 400);
}
- // Floci emulates the aws partition; the live service rejects the others outright, and
- // with a different error than an unresolvable ARN, so this precedes the lookup.
- if (AwsArnUtils.isForeignPartition(AwsArnUtils.parse(layerVersionArn))) {
+ // The live service rejects a layer from another partition outright, and with a different
+ // error than an unresolvable ARN, so this precedes the lookup.
+ if (AwsArnUtils.isForeignPartition(AwsArnUtils.parse(layerVersionArn), regionResolver.getPartition())) {
throw new AwsException("InvalidParameterValueException",
"Invalid layer version " + layerVersionArn, 400);
}
@@ -526,7 +526,7 @@ public class LambdaLayerService {
* to reject too, or Floci would persist an ARN its own lookup path calls invalid.
*/
public boolean isForeignPartitionLayerArn(String layerVersionArn) {
- return AwsArnUtils.isForeignPartition(parseLayerVersionArn(layerVersionArn));
+ return AwsArnUtils.isForeignPartition(parseLayerVersionArn(layerVersionArn), regionResolver.getPartition());
}
private AwsArnUtils.Arn parseLayerVersionArn(String layerVersionArn) {
@@ -544,7 +544,7 @@ public class LambdaLayerService {
}
private boolean isForeignLayerArn(AwsArnUtils.Arn arn) {
- return AwsArnUtils.isForeignPartition(arn)
+ return AwsArnUtils.isForeignPartition(arn, regionResolver.getPartition())
|| AwsArnUtils.isForeignAccount(arn, regionResolver.getAccountId());
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutor.java b/src/main/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutor.java
index e61f75ef50..e067f3a600 100644
--- a/src/main/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutor.java
+++ b/src/main/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutor.java
@@ -4,8 +4,11 @@ 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.AwsErrorResponse;
+import io.github.hectorvent.floci.core.common.AwsPartition;
+import io.github.hectorvent.floci.core.common.AwsPartitions;
import io.github.hectorvent.floci.core.common.CsvParser;
import io.github.hectorvent.floci.core.common.CustomResourceLiveness;
+import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.common.RequestContext;
import io.github.hectorvent.floci.core.common.XmlParser;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
@@ -1289,10 +1292,12 @@ public class AslExecutor {
private JsonNode invokeAwsSdkEc2DescribeRegions() {
ObjectNode result = objectMapper.createObjectNode();
ArrayNode regions = objectMapper.createArrayNode();
- for (String name : ec2Service.describeRegions()) {
+ AwsPartition partition = AwsPartitions.byId(
+ RegionResolver.effectivePartition(config.defaultRegion(), config.partitions().id()));
+ for (AwsPartition.Region name : ec2Service.describeRegions(partition, false)) {
ObjectNode region = objectMapper.createObjectNode();
- region.put("RegionName", name);
- region.put("Endpoint", "ec2." + name + ".amazonaws.com");
+ region.put("RegionName", name.id());
+ region.put("Endpoint", partition.regionalHostname("ec2", name.id()));
region.put("OptInStatus", "opt-in-not-required");
regions.add(region);
}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index cc819ebd0c..c0d12fe71f 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -59,6 +59,7 @@ quarkus:
- ec2/*.yaml
- sagemaker/*.yaml
- eks/*.json
+ - aws/*.json
- i18n/*.properties
- org/apache/velocity/runtime/defaults/*.properties
# DriverManager finds the JDBC drivers through ServiceLoader, and the MySQL
@@ -134,6 +135,9 @@ floci:
# Needed for multi-container Docker setups. Example: FLOCI_HOSTNAME=floci
default-region: us-east-1
default-account-id: "000000000000"
+ partitions:
+ # id: aws # Partition served (aws, aws-cn, aws-us-gov, aws-iso, aws-iso-b, aws-iso-e, aws-iso-f, aws-eusc).
+ # Derived from default-region when unset. Env: FLOCI_PARTITIONS_ID
# Shared mock-response config for Textract/Comprehend/Rekognition/Translate. See AiMockConfigLoader.
ai-mock-config-file: ${AI_MOCK_CONFIG:}
storage:
diff --git a/src/main/resources/aws/partitions.json b/src/main/resources/aws/partitions.json
new file mode 100644
index 0000000000..c9c372477b
--- /dev/null
+++ b/src/main/resources/aws/partitions.json
@@ -0,0 +1,1864 @@
+{
+ "_source": {
+ "generator": "tools/aws/regen_partitions.py",
+ "botocore": "botocore 1.43.98 (local/aws/botocore)",
+ "partitionsJsonVersion": "1.1",
+ "endpointsJsonVersion": 3,
+ "regionFlags": "aws-cdk region-info/lib/aws-entities.ts rules"
+ },
+ "partitions": [
+ {
+ "id": "aws",
+ "name": "AWS Standard",
+ "dnsSuffix": "amazonaws.com",
+ "dualStackDnsSuffix": "api.aws",
+ "implicitGlobalRegion": "us-east-1",
+ "regionRegex": "^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": "aws-global",
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "af-south-1",
+ "description": "Africa (Cape Town)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-east-1",
+ "description": "Asia Pacific (Hong Kong)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-east-2",
+ "description": "Asia Pacific (Taipei)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-northeast-1",
+ "description": "Asia Pacific (Tokyo)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ },
+ {
+ "id": "ap-northeast-2",
+ "description": "Asia Pacific (Seoul)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-northeast-3",
+ "description": "Asia Pacific (Osaka)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-south-1",
+ "description": "Asia Pacific (Mumbai)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-south-2",
+ "description": "Asia Pacific (Hyderabad)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-southeast-1",
+ "description": "Asia Pacific (Singapore)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ },
+ {
+ "id": "ap-southeast-2",
+ "description": "Asia Pacific (Sydney)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ },
+ {
+ "id": "ap-southeast-3",
+ "description": "Asia Pacific (Jakarta)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-southeast-4",
+ "description": "Asia Pacific (Melbourne)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-southeast-5",
+ "description": "Asia Pacific (Malaysia)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-southeast-6",
+ "description": "Asia Pacific (New Zealand)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ap-southeast-7",
+ "description": "Asia Pacific (Thailand)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ca-central-1",
+ "description": "Canada (Central)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "ca-west-1",
+ "description": "Canada West (Calgary)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "eu-central-1",
+ "description": "Europe (Frankfurt)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "eu-central-2",
+ "description": "Europe (Zurich)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "eu-north-1",
+ "description": "Europe (Stockholm)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "eu-south-1",
+ "description": "Europe (Milan)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "eu-south-2",
+ "description": "Europe (Spain)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "eu-west-1",
+ "description": "Europe (Ireland)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ },
+ {
+ "id": "eu-west-2",
+ "description": "Europe (London)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "eu-west-3",
+ "description": "Europe (Paris)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "il-central-1",
+ "description": "Israel (Tel Aviv)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "me-central-1",
+ "description": "Middle East (UAE)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "me-south-1",
+ "description": "Middle East (Bahrain)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "mx-central-1",
+ "description": "Mexico (Central)",
+ "optIn": true,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "sa-east-1",
+ "description": "South America (Sao Paulo)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ },
+ {
+ "id": "us-east-1",
+ "description": "US East (N. Virginia)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ },
+ {
+ "id": "us-east-2",
+ "description": "US East (Ohio)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "us-west-1",
+ "description": "US West (N. California)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ },
+ {
+ "id": "us-west-2",
+ "description": "US West (Oregon)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ }
+ ],
+ "services": [
+ "access-analyzer",
+ "account",
+ "acm",
+ "acm-pca",
+ "agreement-marketplace",
+ "airflow",
+ "amplify",
+ "amplifybackend",
+ "amplifyuibuilder",
+ "aoss",
+ "api.detective",
+ "api.ecr",
+ "api.ecr-public",
+ "api.iotdeviceadvisor",
+ "api.iotwireless",
+ "api.mediatailor",
+ "api.pricing",
+ "api.sagemaker",
+ "api.tunneling.iot",
+ "apigateway",
+ "app-integrations",
+ "appconfig",
+ "appconfigdata",
+ "appflow",
+ "application-autoscaling",
+ "applicationinsights",
+ "appmesh",
+ "apprunner",
+ "appstream2",
+ "appsync",
+ "aps",
+ "arc-zonal-shift",
+ "athena",
+ "auditmanager",
+ "autoscaling",
+ "autoscaling-plans",
+ "backup",
+ "backup-gateway",
+ "batch",
+ "bedrock",
+ "billingconductor",
+ "braket",
+ "budgets",
+ "cases",
+ "cassandra",
+ "catalog.marketplace",
+ "ce",
+ "chime",
+ "cleanrooms",
+ "cloud9",
+ "cloudcontrolapi",
+ "clouddirectory",
+ "cloudformation",
+ "cloudfront",
+ "cloudhsm",
+ "cloudhsmv2",
+ "cloudsearch",
+ "cloudtrail",
+ "cloudtrail-data",
+ "codeartifact",
+ "codebuild",
+ "codecatalyst",
+ "codecommit",
+ "codedeploy",
+ "codeguru-profiler",
+ "codeguru-reviewer",
+ "codepipeline",
+ "codestar-connections",
+ "codestar-notifications",
+ "cognito-identity",
+ "cognito-idp",
+ "cognito-sync",
+ "comprehend",
+ "comprehendmedical",
+ "compute-optimizer",
+ "config",
+ "connect",
+ "connect-campaigns",
+ "contact-lens",
+ "controltower",
+ "cost-optimization-hub",
+ "cur",
+ "data-ats.iot",
+ "data.iot",
+ "data.jobs.iot",
+ "data.mediastore",
+ "databrew",
+ "dataexchange",
+ "datapipeline",
+ "datasync",
+ "datazone",
+ "dax",
+ "devicefarm",
+ "devops-guru",
+ "directconnect",
+ "discovery",
+ "dlm",
+ "dms",
+ "docdb",
+ "drs",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "edge.sagemaker",
+ "eks",
+ "eks-auth",
+ "elasticache",
+ "elasticbeanstalk",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "email",
+ "emr-containers",
+ "emr-serverless",
+ "entitlement.marketplace",
+ "es",
+ "events",
+ "finspace",
+ "finspace-api",
+ "firehose",
+ "fms",
+ "forecast",
+ "forecastquery",
+ "frauddetector",
+ "fsx",
+ "gamelift",
+ "gameliftstreams",
+ "geo",
+ "glacier",
+ "globalaccelerator",
+ "glue",
+ "grafana",
+ "greengrass",
+ "groundstation",
+ "guardduty",
+ "health",
+ "healthlake",
+ "iam",
+ "identity-chime",
+ "identitystore",
+ "importexport",
+ "ingest.timestream",
+ "inspector",
+ "inspector2",
+ "internetmonitor",
+ "iot",
+ "iotfleetwise",
+ "iotsecuredtunneling",
+ "iotsitewise",
+ "iotthingsgraph",
+ "iottwinmaker",
+ "iotwireless",
+ "ivs",
+ "ivschat",
+ "ivsrealtime",
+ "kafka",
+ "kafkaconnect",
+ "kendra",
+ "kendra-ranking",
+ "kinesis",
+ "kinesisanalytics",
+ "kinesisvideo",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "license-manager-linux-subscriptions",
+ "license-manager-user-subscriptions",
+ "lightsail",
+ "logs",
+ "lookoutequipment",
+ "m2",
+ "machinelearning",
+ "macie2",
+ "managedblockchain",
+ "managedblockchain-query",
+ "marketplacecommerceanalytics",
+ "media-pipelines-chime",
+ "mediaconnect",
+ "mediaconvert",
+ "medialive",
+ "mediapackage",
+ "mediapackage-vod",
+ "mediapackagev2",
+ "mediastore",
+ "meetings-chime",
+ "memory-db",
+ "messaging-chime",
+ "metering.marketplace",
+ "metrics.sagemaker",
+ "mgh",
+ "mgn",
+ "migrationhub-orchestrator",
+ "migrationhub-strategy",
+ "mobileanalytics",
+ "models-v2-lex",
+ "models.lex",
+ "monitoring",
+ "mq",
+ "mturk-requester",
+ "neptune",
+ "network-firewall",
+ "networkmanager",
+ "notifications",
+ "notifications-contacts",
+ "nova-act",
+ "oam",
+ "oidc",
+ "omics",
+ "organizations",
+ "osis",
+ "outposts",
+ "participant.connect",
+ "partnercentral-channel",
+ "personalize",
+ "pi",
+ "pinpoint",
+ "pipes",
+ "polly",
+ "portal.sso",
+ "profile",
+ "proton",
+ "qbusiness",
+ "query.timestream",
+ "quicksight",
+ "ram",
+ "rbin",
+ "rds",
+ "rds-data",
+ "redshift",
+ "redshift-serverless",
+ "rekognition",
+ "resiliencehub",
+ "resource-explorer-2",
+ "resource-groups",
+ "rolesanywhere",
+ "route53",
+ "route53-recovery-control-config",
+ "route53domains",
+ "route53profiles",
+ "route53resolver",
+ "rum",
+ "runtime-v2-lex",
+ "runtime.lex",
+ "runtime.sagemaker",
+ "s3",
+ "s3-control",
+ "s3-outposts",
+ "sagemaker-geospatial",
+ "savingsplans",
+ "scheduler",
+ "schemas",
+ "sdb",
+ "secretsmanager",
+ "securityhub",
+ "securitylake",
+ "serverlessrepo",
+ "servicecatalog",
+ "servicecatalog-appregistry",
+ "servicediscovery",
+ "servicequotas",
+ "shield",
+ "signer",
+ "sms-voice",
+ "snowball",
+ "sns",
+ "sqs",
+ "ssm",
+ "ssm-contacts",
+ "ssm-incidents",
+ "ssm-quicksetup",
+ "ssm-sap",
+ "sso",
+ "states",
+ "storagegateway",
+ "streams.dynamodb",
+ "sts",
+ "support",
+ "supportapp",
+ "swf",
+ "synthetics",
+ "tagging",
+ "tax",
+ "textract",
+ "thinclient",
+ "tnb",
+ "transcribe",
+ "transcribestreaming",
+ "transfer",
+ "translate",
+ "trustedadvisor",
+ "verifiedpermissions",
+ "voice-chime",
+ "voiceid",
+ "vpc-lattice",
+ "waf",
+ "waf-regional",
+ "wafv2",
+ "wellarchitected",
+ "wisdom",
+ "workdocs",
+ "workmail",
+ "workspaces",
+ "workspaces-web",
+ "xray"
+ ],
+ "globalServices": {
+ "account": {
+ "hostname": "account.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "billingconductor": {
+ "hostname": "billingconductor.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "budgets": {
+ "hostname": "budgets.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "ce": {
+ "hostname": "ce.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "chime": {
+ "hostname": "chime.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "cloudfront": {
+ "hostname": "cloudfront.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "codecatalyst": {
+ "hostname": "codecatalyst.global.api.aws",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "health": {
+ "hostname": "global.health.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "iam": {
+ "hostname": "iam.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "importexport": {
+ "hostname": "importexport.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "networkmanager": {
+ "hostname": "networkmanager.us-west-2.amazonaws.com",
+ "signingRegion": "us-west-2",
+ "regionalized": false
+ },
+ "notifications-contacts": {
+ "hostname": "notifications-contacts.us-east-1.api.aws",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "organizations": {
+ "hostname": "organizations.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "route53": {
+ "hostname": "route53.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "s3": {
+ "hostname": "s3.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": true
+ },
+ "savingsplans": {
+ "hostname": "savingsplans.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "shield": {
+ "hostname": "shield.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "sts": {
+ "hostname": "sts.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": true
+ },
+ "support": {
+ "hostname": "support.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": true
+ },
+ "tax": {
+ "hostname": "tax.us-east-1.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ },
+ "waf": {
+ "hostname": "waf.amazonaws.com",
+ "signingRegion": "us-east-1",
+ "regionalized": false
+ }
+ }
+ },
+ {
+ "id": "aws-cn",
+ "name": "AWS China",
+ "dnsSuffix": "amazonaws.com.cn",
+ "dualStackDnsSuffix": "api.amazonwebservices.com.cn",
+ "implicitGlobalRegion": "cn-northwest-1",
+ "regionRegex": "^cn\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": "aws-cn-global",
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "cn-north-1",
+ "description": "China (Beijing)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "cn-northwest-1",
+ "description": "China (Ningxia)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ }
+ ],
+ "services": [
+ "access-analyzer",
+ "account",
+ "acm",
+ "acm-pca",
+ "airflow",
+ "api.ecr",
+ "api.pricing",
+ "api.sagemaker",
+ "api.tunneling.iot",
+ "apigateway",
+ "appconfig",
+ "appconfigdata",
+ "application-autoscaling",
+ "applicationinsights",
+ "appmesh",
+ "appsync",
+ "arc-zonal-shift",
+ "athena",
+ "autoscaling",
+ "autoscaling-plans",
+ "backup",
+ "batch",
+ "budgets",
+ "cassandra",
+ "ce",
+ "cloudcontrolapi",
+ "cloudformation",
+ "cloudfront",
+ "cloudtrail",
+ "codebuild",
+ "codecommit",
+ "codedeploy",
+ "codepipeline",
+ "cognito-identity",
+ "compute-optimizer",
+ "config",
+ "cur",
+ "data-ats.iot",
+ "data.iot",
+ "data.jobs.iot",
+ "databrew",
+ "datasync",
+ "datazone",
+ "dax",
+ "directconnect",
+ "dlm",
+ "dms",
+ "docdb",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "eks",
+ "eks-auth",
+ "elasticache",
+ "elasticbeanstalk",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "emr-containers",
+ "emr-serverless",
+ "entitlement.marketplace",
+ "es",
+ "events",
+ "firehose",
+ "fms",
+ "fsx",
+ "gamelift",
+ "gameliftstreams",
+ "glacier",
+ "glue",
+ "greengrass",
+ "guardduty",
+ "health",
+ "iam",
+ "identitystore",
+ "inspector2",
+ "internetmonitor",
+ "iot",
+ "iotsecuredtunneling",
+ "iotsitewise",
+ "iottwinmaker",
+ "kafka",
+ "kafkaconnect",
+ "kendra-ranking",
+ "kinesis",
+ "kinesisanalytics",
+ "kinesisvideo",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "license-manager-linux-subscriptions",
+ "logs",
+ "mediaconvert",
+ "memory-db",
+ "metering.marketplace",
+ "metrics.sagemaker",
+ "monitoring",
+ "mq",
+ "neptune",
+ "network-firewall",
+ "notifications",
+ "oam",
+ "oidc",
+ "organizations",
+ "personalize",
+ "pi",
+ "pipes",
+ "polly",
+ "portal.sso",
+ "qbusiness",
+ "quicksight",
+ "ram",
+ "rbin",
+ "rds",
+ "redshift",
+ "redshift-serverless",
+ "resource-explorer-2",
+ "resource-groups",
+ "rolesanywhere",
+ "route53",
+ "route53profiles",
+ "route53resolver",
+ "runtime.sagemaker",
+ "s3",
+ "s3-control",
+ "savingsplans",
+ "scheduler",
+ "schemas",
+ "secretsmanager",
+ "securityhub",
+ "serverlessrepo",
+ "servicecatalog",
+ "servicediscovery",
+ "servicequotas",
+ "signer",
+ "snowball",
+ "sns",
+ "sqs",
+ "ssm",
+ "sso",
+ "states",
+ "storagegateway",
+ "streams.dynamodb",
+ "sts",
+ "support",
+ "swf",
+ "synthetics",
+ "tagging",
+ "transcribe",
+ "transcribestreaming",
+ "transfer",
+ "verifiedpermissions",
+ "waf-regional",
+ "wafv2",
+ "workspaces",
+ "xray"
+ ],
+ "globalServices": {
+ "account": {
+ "hostname": "account.cn-northwest-1.amazonaws.com.cn",
+ "signingRegion": "cn-northwest-1",
+ "regionalized": false
+ },
+ "budgets": {
+ "hostname": "budgets.amazonaws.com.cn",
+ "signingRegion": "cn-northwest-1",
+ "regionalized": false
+ },
+ "ce": {
+ "hostname": "ce.cn-northwest-1.amazonaws.com.cn",
+ "signingRegion": "cn-northwest-1",
+ "regionalized": false
+ },
+ "cloudfront": {
+ "hostname": "cloudfront.cn-northwest-1.amazonaws.com.cn",
+ "signingRegion": "cn-northwest-1",
+ "regionalized": false
+ },
+ "health": {
+ "hostname": "global.health.amazonaws.com.cn",
+ "signingRegion": "cn-northwest-1",
+ "regionalized": false
+ },
+ "iam": {
+ "hostname": "iam.cn-north-1.amazonaws.com.cn",
+ "signingRegion": "cn-north-1",
+ "regionalized": false
+ },
+ "organizations": {
+ "hostname": "organizations.cn-northwest-1.amazonaws.com.cn",
+ "signingRegion": "cn-northwest-1",
+ "regionalized": false
+ },
+ "route53": {
+ "hostname": "route53.amazonaws.com.cn",
+ "signingRegion": "cn-northwest-1",
+ "regionalized": false
+ },
+ "support": {
+ "hostname": "support.cn-north-1.amazonaws.com.cn",
+ "signingRegion": "cn-north-1",
+ "regionalized": true
+ }
+ }
+ },
+ {
+ "id": "aws-eusc",
+ "name": "AWS EUSC",
+ "dnsSuffix": "amazonaws.eu",
+ "dualStackDnsSuffix": "api.amazonwebservices.eu",
+ "implicitGlobalRegion": "eusc-de-east-1",
+ "regionRegex": "^eusc\\-(de)\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": null,
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "eusc-de-east-1",
+ "description": "AWS European Sovereign Cloud (Germany)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ }
+ ],
+ "services": [
+ "access-analyzer",
+ "acm",
+ "acm-pca",
+ "agreement-marketplace",
+ "api.ecr",
+ "api.pricing",
+ "api.sagemaker",
+ "apigateway",
+ "appconfig",
+ "appconfigdata",
+ "application-autoscaling",
+ "arc-zonal-shift",
+ "athena",
+ "autoscaling",
+ "backup",
+ "batch",
+ "bedrock",
+ "cloudcontrolapi",
+ "cloudformation",
+ "cloudtrail",
+ "codedeploy",
+ "cognito-identity",
+ "cognito-idp",
+ "compute-optimizer",
+ "config",
+ "controltower",
+ "cost-optimization-hub",
+ "datasync",
+ "datazone",
+ "directconnect",
+ "dlm",
+ "dms",
+ "drs",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "eks",
+ "eks-auth",
+ "elasticache",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "email",
+ "emr-serverless",
+ "entitlement.marketplace",
+ "es",
+ "events",
+ "firehose",
+ "fsx",
+ "gameliftstreams",
+ "glue",
+ "guardduty",
+ "health",
+ "identitystore",
+ "internetmonitor",
+ "kafka",
+ "kendra-ranking",
+ "kinesis",
+ "kinesisanalytics",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "logs",
+ "metering.marketplace",
+ "metrics.sagemaker",
+ "monitoring",
+ "mq",
+ "network-firewall",
+ "notifications",
+ "oam",
+ "oidc",
+ "pi",
+ "polly",
+ "portal.sso",
+ "qbusiness",
+ "ram",
+ "rbin",
+ "rds",
+ "redshift",
+ "redshift-serverless",
+ "resource-groups",
+ "rolesanywhere",
+ "route53profiles",
+ "route53resolver",
+ "rum",
+ "runtime.sagemaker",
+ "s3",
+ "s3-control",
+ "scheduler",
+ "secretsmanager",
+ "securityhub",
+ "servicediscovery",
+ "servicequotas",
+ "signer",
+ "sms-voice",
+ "sns",
+ "sqs",
+ "ssm",
+ "sso",
+ "states",
+ "storagegateway",
+ "streams.dynamodb",
+ "sts",
+ "swf",
+ "synthetics",
+ "tagging",
+ "transfer",
+ "trustedadvisor",
+ "wafv2",
+ "xray"
+ ],
+ "globalServices": {}
+ },
+ {
+ "id": "aws-iso",
+ "name": "AWS ISO (US)",
+ "dnsSuffix": "c2s.ic.gov",
+ "dualStackDnsSuffix": "api.aws.ic.gov",
+ "implicitGlobalRegion": "us-iso-east-1",
+ "regionRegex": "^us\\-iso\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": "aws-iso-global",
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "us-iso-east-1",
+ "description": "US ISO East",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "us-iso-west-1",
+ "description": "US ISO WEST",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ }
+ ],
+ "services": [
+ "acm",
+ "acm-pca",
+ "agreement-marketplace",
+ "api.ecr",
+ "api.pricing",
+ "api.sagemaker",
+ "apigateway",
+ "appconfig",
+ "appconfigdata",
+ "application-autoscaling",
+ "appstream2",
+ "arc-zonal-shift",
+ "athena",
+ "autoscaling",
+ "backup",
+ "batch",
+ "bedrock",
+ "budgets",
+ "ce",
+ "cloudcontrolapi",
+ "cloudformation",
+ "cloudtrail",
+ "codebuild",
+ "codedeploy",
+ "comprehend",
+ "compute-optimizer",
+ "config",
+ "cost-optimization-hub",
+ "datapipeline",
+ "datasync",
+ "directconnect",
+ "dlm",
+ "dms",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "eks",
+ "elasticache",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "emr-serverless",
+ "es",
+ "events",
+ "firehose",
+ "fsx",
+ "glacier",
+ "glue",
+ "guardduty",
+ "health",
+ "iam",
+ "kinesis",
+ "kinesisanalytics",
+ "kinesisvideo",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "logs",
+ "medialive",
+ "mediapackage",
+ "metrics.sagemaker",
+ "monitoring",
+ "mq",
+ "network-firewall",
+ "oam",
+ "organizations",
+ "outposts",
+ "pi",
+ "ram",
+ "rbin",
+ "rds",
+ "redshift",
+ "resource-groups",
+ "route53",
+ "route53resolver",
+ "runtime.sagemaker",
+ "s3",
+ "s3-control",
+ "s3-outposts",
+ "scheduler",
+ "secretsmanager",
+ "securityhub",
+ "servicediscovery",
+ "servicequotas",
+ "snowball",
+ "sns",
+ "sqs",
+ "ssm",
+ "states",
+ "storagegateway",
+ "streams.dynamodb",
+ "sts",
+ "support",
+ "swf",
+ "synthetics",
+ "tagging",
+ "textract",
+ "transcribe",
+ "transcribestreaming",
+ "translate",
+ "wafv2",
+ "workspaces",
+ "xray"
+ ],
+ "globalServices": {
+ "budgets": {
+ "hostname": "budgets.c2s.ic.gov",
+ "signingRegion": "us-iso-east-1",
+ "regionalized": false
+ },
+ "ce": {
+ "hostname": "ce.us-iso-east-1.c2s.ic.gov",
+ "signingRegion": "us-iso-east-1",
+ "regionalized": false
+ },
+ "iam": {
+ "hostname": "iam.us-iso-east-1.c2s.ic.gov",
+ "signingRegion": "us-iso-east-1",
+ "regionalized": false
+ },
+ "organizations": {
+ "hostname": "organizations.us-iso-east-1.c2s.ic.gov",
+ "signingRegion": "us-iso-east-1",
+ "regionalized": false
+ },
+ "route53": {
+ "hostname": "route53.c2s.ic.gov",
+ "signingRegion": "us-iso-east-1",
+ "regionalized": false
+ },
+ "support": {
+ "hostname": "support.us-iso-east-1.c2s.ic.gov",
+ "signingRegion": "us-iso-east-1",
+ "regionalized": true
+ }
+ }
+ },
+ {
+ "id": "aws-iso-b",
+ "name": "AWS ISOB (US)",
+ "dnsSuffix": "sc2s.sgov.gov",
+ "dualStackDnsSuffix": "api.aws.scloud",
+ "implicitGlobalRegion": "us-isob-east-1",
+ "regionRegex": "^us\\-isob\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": "aws-iso-b-global",
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "us-isob-east-1",
+ "description": "US ISOB East (Ohio)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "us-isob-west-1",
+ "description": "US ISOB West",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ }
+ ],
+ "services": [
+ "acm",
+ "agreement-marketplace",
+ "api.ecr",
+ "api.pricing",
+ "api.sagemaker",
+ "apigateway",
+ "appconfig",
+ "appconfigdata",
+ "application-autoscaling",
+ "appstream2",
+ "arc-zonal-shift",
+ "athena",
+ "autoscaling",
+ "backup",
+ "batch",
+ "bedrock",
+ "budgets",
+ "ce",
+ "cloudcontrolapi",
+ "cloudformation",
+ "cloudtrail",
+ "codebuild",
+ "codedeploy",
+ "compute-optimizer",
+ "config",
+ "cost-optimization-hub",
+ "datasync",
+ "directconnect",
+ "dlm",
+ "dms",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "eks",
+ "elasticache",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "emr-serverless",
+ "es",
+ "events",
+ "firehose",
+ "fsx",
+ "glacier",
+ "glue",
+ "guardduty",
+ "health",
+ "iam",
+ "kinesis",
+ "kinesisanalytics",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "logs",
+ "medialive",
+ "mediapackage",
+ "metering.marketplace",
+ "metrics.sagemaker",
+ "monitoring",
+ "network-firewall",
+ "oam",
+ "organizations",
+ "outposts",
+ "pi",
+ "ram",
+ "rbin",
+ "rds",
+ "redshift",
+ "resource-groups",
+ "route53",
+ "route53resolver",
+ "runtime.sagemaker",
+ "s3",
+ "s3-control",
+ "s3-outposts",
+ "scheduler",
+ "secretsmanager",
+ "securityhub",
+ "servicediscovery",
+ "servicequotas",
+ "snowball",
+ "sns",
+ "sqs",
+ "ssm",
+ "states",
+ "storagegateway",
+ "streams.dynamodb",
+ "sts",
+ "support",
+ "swf",
+ "synthetics",
+ "tagging",
+ "wafv2",
+ "workspaces",
+ "xray"
+ ],
+ "globalServices": {
+ "budgets": {
+ "hostname": "budgets.global.sc2s.sgov.gov",
+ "signingRegion": "us-isob-east-1",
+ "regionalized": false
+ },
+ "ce": {
+ "hostname": "ce.us-isob-east-1.sc2s.sgov.gov",
+ "signingRegion": "us-isob-east-1",
+ "regionalized": false
+ },
+ "iam": {
+ "hostname": "iam.us-isob-east-1.sc2s.sgov.gov",
+ "signingRegion": "us-isob-east-1",
+ "regionalized": false
+ },
+ "organizations": {
+ "hostname": "organizations.us-isob-east-1.sc2s.sgov.gov",
+ "signingRegion": "us-isob-east-1",
+ "regionalized": false
+ },
+ "route53": {
+ "hostname": "route53.sc2s.sgov.gov",
+ "signingRegion": "us-isob-east-1",
+ "regionalized": false
+ },
+ "support": {
+ "hostname": "support.us-isob-east-1.sc2s.sgov.gov",
+ "signingRegion": "us-isob-east-1",
+ "regionalized": true
+ }
+ }
+ },
+ {
+ "id": "aws-iso-e",
+ "name": "AWS ISOE (Europe)",
+ "dnsSuffix": "cloud.adc-e.uk",
+ "dualStackDnsSuffix": "api.cloud-aws.adc-e.uk",
+ "implicitGlobalRegion": "eu-isoe-west-1",
+ "regionRegex": "^eu\\-isoe\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": "aws-iso-e-global",
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "eu-isoe-west-1",
+ "description": "EU ISOE West",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ }
+ ],
+ "services": [
+ "access-analyzer",
+ "acm",
+ "acm-pca",
+ "api.ecr",
+ "api.pricing",
+ "api.sagemaker",
+ "apigateway",
+ "appconfig",
+ "appconfigdata",
+ "application-autoscaling",
+ "arc-zonal-shift",
+ "athena",
+ "autoscaling",
+ "batch",
+ "budgets",
+ "cloudcontrolapi",
+ "cloudformation",
+ "cloudtrail",
+ "cloudtrail-data",
+ "codedeploy",
+ "compute-optimizer",
+ "config",
+ "cost-optimization-hub",
+ "directconnect",
+ "dlm",
+ "dms",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "eks",
+ "elasticache",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "emr-serverless",
+ "es",
+ "events",
+ "firehose",
+ "glue",
+ "health",
+ "kinesis",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "logs",
+ "metrics.sagemaker",
+ "monitoring",
+ "oam",
+ "organizations",
+ "pi",
+ "pipes",
+ "ram",
+ "rbin",
+ "rds",
+ "redshift",
+ "redshift-serverless",
+ "rekognition",
+ "resource-groups",
+ "rolesanywhere",
+ "route53",
+ "route53profiles",
+ "route53resolver",
+ "s3",
+ "savingsplans",
+ "scheduler",
+ "schemas",
+ "secretsmanager",
+ "servicecatalog",
+ "servicediscovery",
+ "servicequotas",
+ "sns",
+ "sqs",
+ "ssm",
+ "states",
+ "streams.dynamodb",
+ "sts",
+ "swf",
+ "synthetics",
+ "tagging",
+ "trustedadvisor",
+ "xray"
+ ],
+ "globalServices": {
+ "budgets": {
+ "hostname": "budgets.global.cloud.adc-e.uk",
+ "signingRegion": "eu-isoe-west-1",
+ "regionalized": false
+ },
+ "organizations": {
+ "hostname": "organizations.eu-isoe-west-1.cloud.adc-e.uk",
+ "signingRegion": "eu-isoe-west-1",
+ "regionalized": false
+ },
+ "route53": {
+ "hostname": "route53.cloud.adc-e.uk",
+ "signingRegion": "eu-isoe-west-1",
+ "regionalized": false
+ },
+ "savingsplans": {
+ "hostname": "savingsplans.cloud.adc-e.uk",
+ "signingRegion": "eu-isoe-west-1",
+ "regionalized": false
+ }
+ }
+ },
+ {
+ "id": "aws-iso-f",
+ "name": "AWS ISOF",
+ "dnsSuffix": "csp.hci.ic.gov",
+ "dualStackDnsSuffix": "api.aws.hci.ic.gov",
+ "implicitGlobalRegion": "us-isof-south-1",
+ "regionRegex": "^us\\-isof\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": "aws-iso-f-global",
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "us-isof-east-1",
+ "description": "US ISOF EAST",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "us-isof-south-1",
+ "description": "US ISOF SOUTH",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ }
+ ],
+ "services": [
+ "access-analyzer",
+ "acm",
+ "acm-pca",
+ "agreement-marketplace",
+ "api.ecr",
+ "api.pricing",
+ "api.sagemaker",
+ "appconfig",
+ "appconfigdata",
+ "application-autoscaling",
+ "arc-zonal-shift",
+ "athena",
+ "autoscaling",
+ "backup",
+ "batch",
+ "bedrock",
+ "budgets",
+ "ce",
+ "cloudcontrolapi",
+ "cloudformation",
+ "cloudtrail",
+ "cloudtrail-data",
+ "codebuild",
+ "codedeploy",
+ "codepipeline",
+ "comprehend",
+ "compute-optimizer",
+ "config",
+ "cost-optimization-hub",
+ "directconnect",
+ "dlm",
+ "dms",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "eks",
+ "elasticache",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "es",
+ "events",
+ "firehose",
+ "fsx",
+ "glue",
+ "guardduty",
+ "health",
+ "iam",
+ "identitystore",
+ "kinesis",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "logs",
+ "metrics.sagemaker",
+ "monitoring",
+ "oam",
+ "organizations",
+ "pi",
+ "pipes",
+ "quicksight",
+ "ram",
+ "rbin",
+ "rds",
+ "redshift",
+ "redshift-serverless",
+ "rekognition",
+ "resource-groups",
+ "rolesanywhere",
+ "route53",
+ "route53profiles",
+ "route53resolver",
+ "runtime.sagemaker",
+ "s3",
+ "savingsplans",
+ "scheduler",
+ "schemas",
+ "secretsmanager",
+ "securityhub",
+ "servicediscovery",
+ "servicequotas",
+ "sns",
+ "sqs",
+ "ssm",
+ "states",
+ "streams.dynamodb",
+ "sts",
+ "swf",
+ "synthetics",
+ "tagging",
+ "textract",
+ "transcribe",
+ "transcribestreaming",
+ "translate",
+ "trustedadvisor",
+ "xray"
+ ],
+ "globalServices": {
+ "budgets": {
+ "hostname": "budgets.global.csp.hci.ic.gov",
+ "signingRegion": "us-isof-south-1",
+ "regionalized": false
+ },
+ "ce": {
+ "hostname": "ce.us-isof-south-1.csp.hci.ic.gov",
+ "signingRegion": "us-isof-south-1",
+ "regionalized": false
+ },
+ "iam": {
+ "hostname": "iam.us-isof-south-1.csp.hci.ic.gov",
+ "signingRegion": "us-isof-south-1",
+ "regionalized": false
+ },
+ "organizations": {
+ "hostname": "organizations.us-isof-south-1.csp.hci.ic.gov",
+ "signingRegion": "us-isof-south-1",
+ "regionalized": false
+ },
+ "route53": {
+ "hostname": "route53.csp.hci.ic.gov",
+ "signingRegion": "us-isof-south-1",
+ "regionalized": false
+ },
+ "savingsplans": {
+ "hostname": "savingsplans.csp.hci.ic.gov",
+ "signingRegion": "us-isof-south-1",
+ "regionalized": false
+ }
+ }
+ },
+ {
+ "id": "aws-us-gov",
+ "name": "AWS GovCloud (US)",
+ "dnsSuffix": "amazonaws.com",
+ "dualStackDnsSuffix": "api.aws",
+ "implicitGlobalRegion": "us-gov-west-1",
+ "regionRegex": "^us\\-gov\\-\\w+\\-\\d+$",
+ "globalPseudoRegion": "aws-us-gov-global",
+ "supportsDualStack": true,
+ "supportsFips": true,
+ "regions": [
+ {
+ "id": "us-gov-east-1",
+ "description": "AWS GovCloud (US-East)",
+ "optIn": false,
+ "s3WebsiteDashForm": false
+ },
+ {
+ "id": "us-gov-west-1",
+ "description": "AWS GovCloud (US-West)",
+ "optIn": false,
+ "s3WebsiteDashForm": true
+ }
+ ],
+ "services": [
+ "access-analyzer",
+ "acm",
+ "acm-pca",
+ "aoss",
+ "api.detective",
+ "api.ecr",
+ "api.sagemaker",
+ "api.tunneling.iot",
+ "apigateway",
+ "appconfig",
+ "appconfigdata",
+ "application-autoscaling",
+ "applicationinsights",
+ "appstream2",
+ "aps",
+ "arc-zonal-shift",
+ "athena",
+ "autoscaling",
+ "autoscaling-plans",
+ "backup",
+ "backup-gateway",
+ "batch",
+ "bedrock",
+ "cassandra",
+ "cloudcontrolapi",
+ "clouddirectory",
+ "cloudformation",
+ "cloudhsm",
+ "cloudhsmv2",
+ "cloudtrail",
+ "codebuild",
+ "codecommit",
+ "codedeploy",
+ "codepipeline",
+ "codestar-connections",
+ "cognito-identity",
+ "cognito-idp",
+ "comprehend",
+ "comprehendmedical",
+ "compute-optimizer",
+ "config",
+ "connect",
+ "controltower",
+ "data-ats.iot",
+ "data.iot",
+ "data.jobs.iot",
+ "databrew",
+ "datasync",
+ "datazone",
+ "directconnect",
+ "dlm",
+ "dms",
+ "docdb",
+ "drs",
+ "ds",
+ "dynamodb",
+ "ebs",
+ "ec2",
+ "ecs",
+ "eks",
+ "eks-auth",
+ "elasticache",
+ "elasticbeanstalk",
+ "elasticfilesystem",
+ "elasticloadbalancing",
+ "elasticmapreduce",
+ "email",
+ "emr-containers",
+ "emr-serverless",
+ "es",
+ "events",
+ "firehose",
+ "fms",
+ "fsx",
+ "gameliftstreams",
+ "geo",
+ "glacier",
+ "glue",
+ "grafana",
+ "greengrass",
+ "guardduty",
+ "health",
+ "iam",
+ "identitystore",
+ "ingest.timestream",
+ "inspector",
+ "inspector2",
+ "internetmonitor",
+ "iot",
+ "iotsecuredtunneling",
+ "iotsitewise",
+ "iottwinmaker",
+ "kafka",
+ "kafkaconnect",
+ "kendra",
+ "kendra-ranking",
+ "kinesis",
+ "kinesisanalytics",
+ "kinesisvideo",
+ "kms",
+ "lakeformation",
+ "lambda",
+ "license-manager",
+ "license-manager-linux-subscriptions",
+ "license-manager-user-subscriptions",
+ "logs",
+ "m2",
+ "managedblockchain",
+ "mediaconvert",
+ "meetings-chime",
+ "memory-db",
+ "metering.marketplace",
+ "metrics.sagemaker",
+ "mgn",
+ "models-v2-lex",
+ "models.lex",
+ "monitoring",
+ "mq",
+ "neptune",
+ "network-firewall",
+ "networkmanager",
+ "notifications",
+ "oam",
+ "oidc",
+ "organizations",
+ "osis",
+ "outposts",
+ "participant.connect",
+ "pi",
+ "pinpoint",
+ "polly",
+ "portal.sso",
+ "qbusiness",
+ "query.timestream",
+ "quicksight",
+ "ram",
+ "rbin",
+ "rds",
+ "redshift",
+ "redshift-serverless",
+ "rekognition",
+ "resiliencehub",
+ "resource-explorer-2",
+ "resource-groups",
+ "rolesanywhere",
+ "route53",
+ "route53profiles",
+ "route53resolver",
+ "rum",
+ "runtime-v2-lex",
+ "runtime.lex",
+ "runtime.sagemaker",
+ "s3",
+ "s3-control",
+ "s3-outposts",
+ "scheduler",
+ "schemas",
+ "secretsmanager",
+ "securityhub",
+ "securitylake",
+ "serverlessrepo",
+ "servicecatalog",
+ "servicecatalog-appregistry",
+ "servicediscovery",
+ "servicequotas",
+ "signer",
+ "sms-voice",
+ "snowball",
+ "sns",
+ "sqs",
+ "ssm",
+ "sso",
+ "states",
+ "storagegateway",
+ "streams.dynamodb",
+ "sts",
+ "support",
+ "swf",
+ "synthetics",
+ "tagging",
+ "textract",
+ "transcribe",
+ "transcribestreaming",
+ "transfer",
+ "translate",
+ "verifiedpermissions",
+ "waf-regional",
+ "wafv2",
+ "wellarchitected",
+ "workspaces",
+ "xray"
+ ],
+ "globalServices": {
+ "iam": {
+ "hostname": "iam.us-gov.amazonaws.com",
+ "signingRegion": "us-gov-west-1",
+ "regionalized": false
+ },
+ "networkmanager": {
+ "hostname": "networkmanager.us-gov-west-1.amazonaws.com",
+ "signingRegion": "us-gov-west-1",
+ "regionalized": false
+ },
+ "organizations": {
+ "hostname": "organizations.us-gov-west-1.amazonaws.com",
+ "signingRegion": "us-gov-west-1",
+ "regionalized": false
+ },
+ "route53": {
+ "hostname": "route53.us-gov.amazonaws.com",
+ "signingRegion": "us-gov-west-1",
+ "regionalized": false
+ },
+ "support": {
+ "hostname": "support.us-gov-west-1.amazonaws.com",
+ "signingRegion": "us-gov-west-1",
+ "regionalized": true
+ }
+ }
+ }
+ ]
+}
diff --git a/src/test/java/io/github/hectorvent/floci/config/PartitionStartupValidatorTest.java b/src/test/java/io/github/hectorvent/floci/config/PartitionStartupValidatorTest.java
new file mode 100644
index 0000000000..966c9bd844
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/config/PartitionStartupValidatorTest.java
@@ -0,0 +1,64 @@
+package io.github.hectorvent.floci.config;
+
+import io.github.hectorvent.floci.core.common.AwsPartition;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import java.util.Optional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class PartitionStartupValidatorTest {
+
+ @ParameterizedTest
+ @CsvSource({
+ "us-east-1, aws",
+ "cn-north-1, aws-cn",
+ "us-gov-west-1, aws-us-gov",
+ "us-iso-east-1, aws-iso",
+ "us-isob-east-1, aws-iso-b",
+ "eu-isoe-west-1, aws-iso-e",
+ "us-isof-south-1, aws-iso-f",
+ "eusc-de-east-1, aws-eusc"})
+ void thePartitionIsDerivedFromTheDefaultRegion(String region, String partition) {
+ AwsPartition resolved = PartitionStartupValidator.validate(region, Optional.empty());
+ assertEquals(partition, resolved.id());
+ }
+
+ @Test
+ void anExplicitPartitionThatAgreesWithTheRegionIsAccepted() {
+ assertEquals("aws-cn", PartitionStartupValidator.validate("cn-north-1", Optional.of("aws-cn")).id());
+ assertEquals("aws-cn", PartitionStartupValidator.validate("cn-north-1", Optional.of(" AWS-CN ")).id());
+ }
+
+ @Test
+ void anUnknownPartitionIdIsRefused() {
+ IllegalStateException error = assertThrows(IllegalStateException.class,
+ () -> PartitionStartupValidator.validate("us-east-1", Optional.of("aws-mars")));
+ assertTrue(error.getMessage().contains("aws-mars"));
+ assertTrue(error.getMessage().contains("aws-cn"), "the message lists the published partitions");
+ }
+
+ @Test
+ void aPartitionThatContradictsARecognisedRegionIsRefused() {
+ IllegalStateException error = assertThrows(IllegalStateException.class,
+ () -> PartitionStartupValidator.validate("cn-north-1", Optional.of("aws")));
+ assertTrue(error.getMessage().contains("cn-north-1"));
+ assertTrue(error.getMessage().contains("aws-cn"));
+ }
+
+ /** A region the vendored data does not know only warns; the explicit partition wins. */
+ @Test
+ void anUnpublishedRegionIsAcceptedWithAWarning() {
+ assertEquals("aws-us-gov", PartitionStartupValidator.validate("us-gov-north-9", Optional.of("aws-us-gov")).id());
+ assertEquals("aws", PartitionStartupValidator.validate("xx-nowhere-9", Optional.empty()).id());
+ }
+
+ @Test
+ void aBlankPartitionIdMeansUnset() {
+ assertEquals("aws-us-gov", PartitionStartupValidator.validate("us-gov-west-1", Optional.of(" ")).id());
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/AccountContextFilterTest.java b/src/test/java/io/github/hectorvent/floci/core/common/AccountContextFilterTest.java
index 1cd14a272c..248b4c2524 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/AccountContextFilterTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/AccountContextFilterTest.java
@@ -72,6 +72,46 @@ class AccountContextFilterTest {
filter.filter(ctx);
assertEquals(DEFAULT_ACCOUNT, requestContext.getAccountId());
assertEquals(DEFAULT_REGION, requestContext.getRegion());
+ assertEquals("aws", requestContext.getPartition());
+ }
+
+ /** The signing region carries the partition: a China-signed request is a China request. */
+ @Test
+ void partitionFollowsTheSigningRegionOfTheAuthorizationHeader() {
+ filter.filter(mockContext(
+ "AWS4-HMAC-SHA256 Credential=000000000001/20260617/cn-north-1/iam/aws4_request, SignedHeaders=host, Signature=abc",
+ null));
+ assertEquals("cn-north-1", requestContext.getRegion());
+ assertEquals("aws-cn", requestContext.getPartition());
+
+ filter.filter(mockContext(
+ "AWS4-HMAC-SHA256 Credential=000000000001/20260617/eusc-de-east-1/sqs/aws4_request, SignedHeaders=host, Signature=abc",
+ null));
+ assertEquals("aws-eusc", requestContext.getPartition());
+
+ filter.filter(mockContext(
+ "AWS4-HMAC-SHA256 Credential=000000000001/20260617/aws-cn-global/iam/aws4_request, SignedHeaders=host, Signature=abc",
+ null));
+ assertEquals("aws-cn-global", requestContext.getRegion());
+ assertEquals("aws-cn", requestContext.getPartition());
+ }
+
+ @Test
+ void partitionFollowsThePresignedCredentialRegion() {
+ filter.filter(mockContext(null, "000000000002/20260617/us-gov-west-1/s3/aws4_request"));
+ assertEquals("us-gov-west-1", requestContext.getRegion());
+ assertEquals("aws-us-gov", requestContext.getPartition());
+ }
+
+ /** With no credential the request belongs to the deployment's partition, whatever it is. */
+ @Test
+ void anUnsignedRequestGetsTheDeploymentPartition() {
+ RegionResolver china = new RegionResolver("cn-north-1", DEFAULT_ACCOUNT);
+ AccountContextFilter chinaFilter = new AccountContextFilter(accountResolver, china, requestContext,
+ akid -> Optional.empty());
+ chinaFilter.filter(mockContext(null, null));
+ assertEquals("cn-north-1", requestContext.getRegion());
+ assertEquals("aws-cn", requestContext.getPartition());
}
@Test
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/AwsArnOwnershipTest.java b/src/test/java/io/github/hectorvent/floci/core/common/AwsArnOwnershipTest.java
index d5a1c0c6ae..c0978a488f 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/AwsArnOwnershipTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/AwsArnOwnershipTest.java
@@ -21,20 +21,29 @@ class AwsArnOwnershipTest {
@Test
void awsPartitionIsNotForeign() {
assertFalse(AwsArnUtils.isForeignPartition(
- arn("arn:aws:lambda:us-east-1:000000000000:layer:l:1")));
+ arn("arn:aws:lambda:us-east-1:000000000000:layer:l:1"), "aws"));
}
@Test
void otherPartitionsAreForeign() {
assertTrue(AwsArnUtils.isForeignPartition(
- arn("arn:aws-cn:lambda:cn-north-1:000000000000:layer:l:1")));
+ arn("arn:aws-cn:lambda:cn-north-1:000000000000:layer:l:1"), "aws"));
assertTrue(AwsArnUtils.isForeignPartition(
- arn("arn:aws-us-gov:lambda:us-gov-west-1:000000000000:layer:l:1")));
+ arn("arn:aws-us-gov:lambda:us-gov-west-1:000000000000:layer:l:1"), "aws"));
+ }
+
+ /** Foreign is relative to the caller's partition: a China ARN is local to a China request. */
+ @Test
+ void theCallersOwnPartitionIsNotForeign() {
+ assertFalse(AwsArnUtils.isForeignPartition(
+ arn("arn:aws-cn:lambda:cn-north-1:000000000000:layer:l:1"), "aws-cn"));
+ assertTrue(AwsArnUtils.isForeignPartition(
+ arn("arn:aws:lambda:us-east-1:000000000000:layer:l:1"), "aws-cn"));
}
@Test
void anEmptyPartitionIsNotForeign() {
- assertFalse(AwsArnUtils.isForeignPartition(arn("arn::lambda:us-east-1:000000000000:layer:l:1")));
+ assertFalse(AwsArnUtils.isForeignPartition(arn("arn::lambda:us-east-1:000000000000:layer:l:1"), "aws"));
}
@Test
@@ -58,7 +67,7 @@ class AwsArnOwnershipTest {
@Test
void nullIsNotForeign() {
- assertFalse(AwsArnUtils.isForeignPartition(null));
+ assertFalse(AwsArnUtils.isForeignPartition(null, "aws"));
assertFalse(AwsArnUtils.isForeignAccount(null, LOCAL));
}
}
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/AwsArnUtilsTest.java b/src/test/java/io/github/hectorvent/floci/core/common/AwsArnUtilsTest.java
index 51e2c53079..caa979e5f4 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/AwsArnUtilsTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/AwsArnUtilsTest.java
@@ -2,7 +2,10 @@ package io.github.hectorvent.floci.core.common;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
+import io.github.hectorvent.floci.testing.PartitionMatrix;
+import io.github.hectorvent.floci.testing.PartitionMatrix.PartitionCase;
import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -140,8 +143,8 @@ class AwsArnUtilsTest {
}
/**
- * Global services pass no region, and they keep the commercial partition. Thirty call sites
- * do this; anything else would rewrite every IAM, S3 and CloudFront ARN the emulator mints.
+ * A regionless {@code Arn.of} keeps the commercial partition: nothing in the region argument
+ * can say otherwise. Call sites that know the request's partition use {@link AwsArnUtils.Arn#global}.
*/
@Test
void aRegionlessArnStaysInTheCommercialPartition() {
@@ -149,6 +152,20 @@ class AwsArnUtilsTest {
AwsArnUtils.Arn.of("iam", "", "000000000000", "role/r").toString());
}
+ @ParameterizedTest
+ @MethodSource("io.github.hectorvent.floci.testing.PartitionMatrix#cases")
+ void aGlobalArnCarriesTheGivenPartitionAndNoRegion(PartitionCase partitionCase) {
+ AwsArnUtils.Arn arn = AwsArnUtils.Arn.global(partitionCase.partition(), "iam", "000000000000", "role/r");
+ assertEquals("arn:" + partitionCase.partition() + ":iam::000000000000:role/r", arn.toString());
+ PartitionMatrix.assertGlobalArnIn(partitionCase, arn.toString());
+ }
+
+ @Test
+ void aPseudoRegionResolvesToItsPartitionWhenMinting() {
+ assertEquals("arn:aws-cn:sqs:aws-cn-global:000000000000:q",
+ AwsArnUtils.Arn.of("sqs", "aws-cn-global", "000000000000", "q").toString());
+ }
+
/** A region AWS has not launched yet must not fail closed. */
@Test
void anUnrecognisedRegionFallsBackToTheCommercialPartition() {
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/AwsPartitionsTest.java b/src/test/java/io/github/hectorvent/floci/core/common/AwsPartitionsTest.java
new file mode 100644
index 0000000000..86de8f4ff4
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/core/common/AwsPartitionsTest.java
@@ -0,0 +1,238 @@
+package io.github.hectorvent.floci.core.common;
+
+import io.github.hectorvent.floci.testing.PartitionMatrix;
+import io.github.hectorvent.floci.testing.PartitionMatrix.PartitionCase;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.NullAndEmptySource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The vendored partition catalog ({@code aws/partitions.json}) and the lookups over it. The
+ * shape assertions pin what {@code tools/aws/regen_partitions.py} produces from botocore; the
+ * lookup assertions pin the strict-then-fail-open resolution every ARN and hostname relies on.
+ */
+class AwsPartitionsTest {
+
+ private static final Set<String> PUBLISHED_PARTITIONS = Set.of(
+ "aws", "aws-cn", "aws-us-gov", "aws-iso", "aws-iso-b", "aws-iso-e", "aws-iso-f", "aws-eusc");
+
+ @Test
+ void allEightPartitionsArePresentExactlyOnce() {
+ assertEquals(PUBLISHED_PARTITIONS, AwsPartitions.ids());
+ assertEquals(8, AwsPartitions.all().size());
+ }
+
+ @ParameterizedTest
+ @MethodSource("io.github.hectorvent.floci.testing.PartitionMatrix#cases")
+ void everyMatrixRegionResolvesToItsPartitionWithItsDnsSuffix(PartitionCase partitionCase) {
+ AwsPartition partition = AwsPartitions.forRegion(partitionCase.region()).orElseThrow();
+ assertEquals(partitionCase.partition(), partition.id());
+ assertEquals(partitionCase.dnsSuffix(), partition.dnsSuffix());
+ assertTrue(partition.isPublishedRegion(partitionCase.region()));
+ }
+
+ /**
+ * Membership and botocore's regionRegex must agree for every published region, or a region
+ * would resolve one way from the list and another way once the list is stale.
+ */
+ @Test
+ void regionRegexAgreesWithMembershipForEveryPublishedRegion() {
+ for (AwsPartition partition : AwsPartitions.all()) {
+ for (String region : partition.regionIds()) {
+ assertTrue(partition.matchesRegionRegex(region),
+ region + " is listed under " + partition.id() + " but does not match its regionRegex");
+ for (AwsPartition other : AwsPartitions.all()) {
+ if (!other.id().equals(partition.id())) {
+ assertFalse(other.matchesRegionRegex(region),
+ region + " matches the regionRegex of both " + partition.id() + " and " + other.id());
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ void everyKnownRegionIdBelongsToExactlyOnePartition() {
+ for (String region : AwsPartitions.allRegionIds()) {
+ long owners = AwsPartitions.all().stream().filter(p -> p.isPublishedRegion(region)).count();
+ assertEquals(1, owners, region);
+ assertEquals(AwsPartitions.forRegion(region).orElseThrow().id(),
+ AwsPartitions.all().stream().filter(p -> p.isPublishedRegion(region)).findFirst().orElseThrow().id());
+ }
+ }
+
+ @Test
+ void theCommercialPartitionPublishesThirtyFourRegionsAndChinaTwo() {
+ assertEquals(34, AwsPartitions.commercial().regions().size());
+ assertEquals(List.of("cn-north-1", "cn-northwest-1"), AwsPartitions.byId("aws-cn").regionIds());
+ assertEquals(List.of("us-gov-east-1", "us-gov-west-1"), AwsPartitions.byId("aws-us-gov").regionIds());
+ }
+
+ @ParameterizedTest
+ @CsvSource({
+ "aws-global, aws, us-east-1",
+ "aws-cn-global, aws-cn, cn-northwest-1",
+ "aws-us-gov-global, aws-us-gov, us-gov-west-1",
+ "aws-iso-global, aws-iso, us-iso-east-1",
+ "aws-iso-b-global, aws-iso-b, us-isob-east-1",
+ "aws-iso-e-global, aws-iso-e, eu-isoe-west-1",
+ "aws-iso-f-global, aws-iso-f, us-isof-south-1"})
+ void pseudoRegionsResolveToTheirPartitionAndNormalizeToItsImplicitGlobalRegion(
+ String pseudo, String partition, String implicitGlobalRegion) {
+ assertEquals(partition, AwsPartitions.forRegion(pseudo).orElseThrow().id());
+ assertEquals(implicitGlobalRegion, AwsPartitions.normalizeRegion(pseudo));
+ assertEquals(implicitGlobalRegion, AwsPartitions.byId(partition).implicitGlobalRegion());
+ assertTrue(AwsPartitions.byId(partition).isPseudoRegion(pseudo));
+ assertFalse(AwsPartitions.isPublishedRegion(pseudo), "a pseudo-region is not a published region");
+ }
+
+ /** botocore publishes no {@code aws-eusc-global}, and EUSC has no partition-wide service at all. */
+ @Test
+ void euscHasNoPseudoRegionAndNoGlobalServices() {
+ AwsPartition eusc = AwsPartitions.byId("aws-eusc");
+ assertTrue(eusc.pseudoRegion().isEmpty());
+ assertTrue(eusc.globalServices().isEmpty());
+ assertTrue(AwsPartitions.forRegion("aws-eusc-global").isEmpty());
+ }
+
+ /** The global STS host exists only in the commercial partition; everywhere else STS is regional. */
+ @Test
+ void onlyTheCommercialPartitionHasGlobalSts() {
+ for (AwsPartition partition : AwsPartitions.all()) {
+ assertEquals("aws".equals(partition.id()), partition.hasGlobalSts(), partition.id());
+ }
+ AwsPartition.GlobalEndpoint sts = AwsPartitions.commercial().globalEndpoint("sts").orElseThrow();
+ assertEquals("sts.amazonaws.com", sts.hostname());
+ assertEquals("us-east-1", sts.signingRegion());
+ assertTrue(sts.regionalized(), "STS keeps per-region endpoints beside the global host");
+ }
+
+ /** China IAM signs {@code cn-north-1} although the partition's implicit global region is Ningxia. */
+ @Test
+ void globalEndpointsCarryTheirOwnSigningRegion() {
+ AwsPartition china = AwsPartitions.byId("aws-cn");
+ AwsPartition.GlobalEndpoint iam = china.globalEndpoint("iam").orElseThrow();
+ assertEquals("iam.cn-north-1.amazonaws.com.cn", iam.hostname());
+ assertEquals("cn-north-1", iam.signingRegion());
+ assertEquals("cn-northwest-1", china.globalEndpoint("route53").orElseThrow().signingRegion());
+ assertEquals("us-gov-west-1", AwsPartitions.byId("aws-us-gov").globalEndpoint("iam").orElseThrow().signingRegion());
+ }
+
+ @Test
+ void serviceAvailabilityFollowsEndpointsJson() {
+ assertTrue(AwsPartitions.commercial().offers("cloudfront"));
+ assertTrue(AwsPartitions.byId("aws-cn").offers("cloudfront"));
+ assertFalse(AwsPartitions.byId("aws-us-gov").offers("cloudfront"));
+ assertFalse(AwsPartitions.byId("aws-eusc").offers("iam"));
+ assertFalse(AwsPartitions.byId("aws-iso-e").offers("iam"));
+ assertFalse(AwsPartitions.byId("aws-cn").offers("cognito-idp"));
+ assertFalse(AwsPartitions.commercial().offers(null));
+ }
+
+ @Test
+ void optInAndWebsiteFormFlagsComeFromTheCdkRules() {
+ AwsPartition aws = AwsPartitions.commercial();
+ assertFalse(aws.region("us-east-1").orElseThrow().optIn());
+ assertFalse(aws.region("eu-north-1").orElseThrow().optIn(), "the last region before opt-in began");
+ assertTrue(aws.region("ap-east-1").orElseThrow().optIn());
+ assertTrue(aws.region("il-central-1").orElseThrow().optIn());
+ assertTrue(aws.region("us-east-1").orElseThrow().s3WebsiteDashForm());
+ assertTrue(aws.region("us-west-2").orElseThrow().s3WebsiteDashForm());
+ assertTrue(aws.region("ap-southeast-2").orElseThrow().s3WebsiteDashForm());
+ assertFalse(aws.region("eu-central-1").orElseThrow().s3WebsiteDashForm());
+ assertFalse(aws.region("ap-east-1").orElseThrow().s3WebsiteDashForm());
+ assertTrue(AwsPartitions.byId("aws-us-gov").region("us-gov-west-1").orElseThrow().s3WebsiteDashForm());
+ assertFalse(AwsPartitions.byId("aws-cn").region("cn-north-1").orElseThrow().optIn());
+ assertEquals(17, aws.regions().stream().filter(AwsPartition.Region::optIn).count());
+ }
+
+ @ParameterizedTest
+ @NullAndEmptySource
+ @ValueSource(strings = {" ", "xx-nowhere-9", "not-a-region", "us-gov", "cn-north", "aws-eusc-global"})
+ void unplaceableLabelsAreEmptyStrictlyAndCommercialLeniently(String region) {
+ assertTrue(AwsPartitions.forRegion(region).isEmpty());
+ assertEquals("aws", AwsPartitions.forRegionOrCommercial(region).id());
+ }
+
+ /** A region AWS launches after the vendored data is placed by botocore's shape rule. */
+ @Test
+ void anUnlistedRegionOfAKnownShapeResolvesByRegex() {
+ assertEquals("aws-cn", AwsPartitions.forRegion("cn-southwest-9").orElseThrow().id());
+ assertEquals("aws-us-gov", AwsPartitions.forRegion("us-gov-north-3").orElseThrow().id());
+ assertEquals("aws", AwsPartitions.forRegion("eu-nowhere-7").orElseThrow().id());
+ assertFalse(AwsPartitions.isPublishedRegion("eu-nowhere-7"));
+ }
+
+ @Test
+ void lookupsAreCaseInsensitive() {
+ assertEquals("aws-cn", AwsPartitions.forRegion("CN-NORTH-1").orElseThrow().id());
+ assertEquals("aws-cn", AwsPartitions.byId("AWS-CN").id());
+ assertEquals("cn-north-1", AwsPartitions.normalizeRegion(" CN-North-1 "));
+ assertEquals(Optional.empty(), Optional.ofNullable(AwsPartitions.normalizeRegion(null)));
+ }
+
+ @Test
+ void unknownPartitionIdsThrow() {
+ assertThrows(IllegalArgumentException.class, () -> AwsPartitions.byId("aws-mars"));
+ assertTrue(AwsPartitions.find("aws-mars").isEmpty());
+ assertTrue(AwsPartitions.find(null).isEmpty());
+ }
+
+ /**
+ * {@code amazonaws.com.cn} must win over {@code amazonaws.com} or a China host loses its
+ * {@code .cn} and is read as commercial; the dual-stack suffixes are published too.
+ */
+ @ParameterizedTest
+ @CsvSource({
+ "bucket.s3.cn-north-1.amazonaws.com.cn, bucket.s3.cn-north-1, amazonaws.com.cn",
+ "bucket.s3.us-east-1.amazonaws.com, bucket.s3.us-east-1, amazonaws.com",
+ "s3.us-iso-east-1.c2s.ic.gov, s3.us-iso-east-1, c2s.ic.gov",
+ "s3.eusc-de-east-1.amazonaws.eu, s3.eusc-de-east-1, amazonaws.eu",
+ "dynamodb.us-east-1.api.aws, dynamodb.us-east-1, api.aws",
+ "sqs.cn-north-1.api.amazonwebservices.com.cn, sqs.cn-north-1, api.amazonwebservices.com.cn",
+ "BUCKET.S3.CN-NORTH-1.AMAZONAWS.COM.CN, bucket.s3.cn-north-1, amazonaws.com.cn"})
+ void stripKnownDnsSuffixTakesTheLongestSuffixFirst(String host, String prefix, String suffix) {
+ AwsPartitions.DnsSuffixMatch match = AwsPartitions.stripKnownDnsSuffix(host).orElseThrow();
+ assertEquals(prefix, match.prefix());
+ assertEquals(suffix, match.dnsSuffix());
+ }
+
+ @ParameterizedTest
+ @NullAndEmptySource
+ @ValueSource(strings = {"amazonaws.com", "localhost:4566", "bucket.localhost", "example.com", "s3.amazonaws.com.evil"})
+ void hostsWithoutAPublishedSuffixDoNotStrip(String host) {
+ assertTrue(AwsPartitions.stripKnownDnsSuffix(host).isEmpty());
+ }
+
+ @Test
+ void aMalformedCatalogFailsLoudly() {
+ assertThrows(IllegalStateException.class, () -> AwsPartitions.parse(
+ new ByteArrayInputStream("{\"partitions\": []}".getBytes(StandardCharsets.UTF_8))));
+ assertThrows(IllegalStateException.class, () -> AwsPartitions.parse(new ByteArrayInputStream(
+ "{\"partitions\": [{\"id\": \"aws-cn\", \"name\": \"x\", \"dnsSuffix\": \"a\", \"dualStackDnsSuffix\": \"b\", \"implicitGlobalRegion\": \"c\", \"regionRegex\": \"d\"}]}"
+ .getBytes(StandardCharsets.UTF_8))), "a catalog without the commercial partition");
+ assertThrows(IllegalStateException.class, () -> AwsPartitions.parse(new ByteArrayInputStream(
+ "{\"partitions\": [{\"id\": \"aws\", \"name\": \"x\"}]}".getBytes(StandardCharsets.UTF_8))),
+ "a partition missing required fields");
+ }
+
+ @Test
+ void partitionMatrixCoversEveryPublishedPartition() {
+ assertEquals(PUBLISHED_PARTITIONS,
+ Set.copyOf(PartitionMatrix.all().stream().map(PartitionCase::partition).toList()));
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/AwsRegionsTest.java b/src/test/java/io/github/hectorvent/floci/core/common/AwsRegionsTest.java
index 147e6bb70c..7895df14c7 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/AwsRegionsTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/AwsRegionsTest.java
@@ -6,6 +6,8 @@ import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.NullAndEmptySource;
import org.junit.jupiter.params.provider.ValueSource;
+import java.util.List;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -97,17 +99,29 @@ class AwsRegionsTest {
assertEquals("aws-cn", AwsRegions.partitionFor("CN-NORTH-1"));
}
- /** Every GovCloud and China id the emulator recognises must land outside {@code aws}. */
+ /** Every known id resolves to a partition whose published regions contain it. */
@Test
- void knownNonCommercialIdsAreNotCommercial() {
+ void everyKnownIdResolvesToThePartitionThatPublishesIt() {
for (String region : AwsRegions.KNOWN_IDS) {
- if (region.startsWith("us-gov-")) {
- assertEquals("aws-us-gov", AwsRegions.partitionFor(region), region);
- } else if (region.startsWith("cn-")) {
- assertEquals("aws-cn", AwsRegions.partitionFor(region), region);
- } else {
- assertEquals("aws", AwsRegions.partitionFor(region), region);
- }
+ String partition = AwsRegions.partitionFor(region);
+ assertTrue(AwsRegions.advertised(partition).contains(region),
+ region + " resolves to " + partition + ", which does not publish it");
}
}
+
+ @Test
+ void advertisedListsArePerPartition() {
+ assertEquals(AwsRegions.ALL, AwsRegions.advertised("aws"));
+ assertEquals(34, AwsRegions.ALL.size());
+ assertEquals(List.of("cn-north-1", "cn-northwest-1"), AwsRegions.advertised("aws-cn"));
+ assertTrue(AwsRegions.KNOWN_IDS.contains("eusc-de-east-1"));
+ assertTrue(AwsRegions.KNOWN_IDS.contains("us-isof-south-1"));
+ }
+
+ @Test
+ void pseudoRegionsResolveToTheirPartition() {
+ assertEquals("aws-cn", AwsRegions.partitionFor("aws-cn-global"));
+ assertEquals("amazonaws.com.cn", AwsRegions.dnsSuffixFor("aws-cn-global"));
+ assertEquals("aws-us-gov", AwsRegions.partitionFor("aws-us-gov-global"));
+ }
}
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/RegionResolverTest.java b/src/test/java/io/github/hectorvent/floci/core/common/RegionResolverTest.java
index 329c03d13c..85d538b6ab 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/RegionResolverTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/RegionResolverTest.java
@@ -11,6 +11,7 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Optional;
import static org.junit.jupiter.api.Assertions.*;
@@ -172,6 +173,65 @@ class RegionResolverTest {
assertNull(resolver.resolveRegionFromHost(""));
}
+ @Test
+ void theDeploymentPartitionFollowsTheDefaultRegion() {
+ assertEquals("aws", resolver.getDefaultPartition());
+ assertEquals("aws-cn", new RegionResolver("cn-north-1", "000000000000").getDefaultPartition());
+ assertEquals("aws-us-gov", new RegionResolver("us-gov-west-1", "000000000000").getDefaultPartition());
+ assertEquals("aws-iso-b", new RegionResolver("us-isob-east-1", "000000000000", "aws-iso-b").getDefaultPartition());
+ }
+
+ @Test
+ void anExplicitPartitionIdOverridesTheRegionDerivedOne() {
+ assertEquals("aws-cn", RegionResolver.effectivePartition("cn-north-1", Optional.empty()));
+ assertEquals("aws-us-gov", RegionResolver.effectivePartition("us-east-1", Optional.of(" AWS-US-GOV ")));
+ assertEquals("aws", RegionResolver.effectivePartition("us-east-1", Optional.of(" ")));
+ }
+
+ /**
+ * The request's partition comes from its signing region. A blank region (no credential) is
+ * the deployment's partition, never a literal {@code aws}; a pseudo-region resolves to its
+ * partition; and a region the catalog cannot place stays local rather than commercial.
+ */
+ @Test
+ void partitionForRegionScopesARequest() {
+ RegionResolver china = new RegionResolver("cn-north-1", "000000000000");
+ assertEquals("aws-cn", china.partitionForRegion(null));
+ assertEquals("aws-cn", china.partitionForRegion(""));
+ assertEquals("aws-cn", china.partitionForRegion("xx-nowhere-9"));
+ assertEquals("aws", china.partitionForRegion("us-east-1"));
+ assertEquals("aws-us-gov", china.partitionForRegion("us-gov-west-1"));
+ assertEquals("aws-eusc", china.partitionForRegion("eusc-de-east-1"));
+ assertEquals("aws-cn", resolver.partitionForRegion("aws-cn-global"));
+ assertEquals("aws-iso", resolver.partitionForRegion("aws-iso-global"));
+ assertEquals("aws", resolver.partitionForRegion("aws-global"));
+ }
+
+ @Test
+ void getPartitionOutsideARequestIsTheDeploymentPartition() {
+ assertEquals("aws", resolver.getPartition());
+ assertEquals("aws-cn", new RegionResolver("cn-north-1", "000000000000").getPartition());
+ }
+
+ @Test
+ void buildArnRoutesABlankRegionToTheDeploymentPartition() {
+ RegionResolver govCloud = new RegionResolver("us-gov-west-1", "000000000000");
+ assertEquals("arn:aws-us-gov:iam::000000000000:role/r", govCloud.buildArn("iam", "", "role/r"));
+ assertEquals("arn:aws-us-gov:iam::000000000000:role/r", govCloud.buildArn("iam", null, "role/r"));
+ assertEquals("arn:aws-us-gov:s3:::bucket", govCloud.buildGlobalArn("s3", "", "bucket"));
+ assertEquals("arn:aws-us-gov:sqs:us-gov-west-1:000000000000:q", govCloud.buildArn("sqs", "us-gov-west-1", "q"));
+ assertEquals("arn:aws:iam::000000000000:role/r", resolver.buildArn("iam", "", "role/r"));
+ }
+
+ @Test
+ void resolveRegionFromHostAcceptsEveryPartitionsShapeButOnlyPublishedIds() {
+ assertEquals("eusc-de-east-1", resolver.resolveRegionFromHost("abc123.execute-api.eusc-de-east-1.localhost:4566"));
+ assertEquals("us-isob-east-1", resolver.resolveRegionFromHost("abc123.execute-api.us-isob-east-1.localhost"));
+ assertEquals("cn-north-1", resolver.resolveRegionFromHost("abc123.execute-api.cn-north-1.amazonaws.com.cn"));
+ assertNull(resolver.resolveRegionFromHost("abc123.execute-api.xx-nowhere-9.localhost:4566"));
+ assertNull(resolver.resolveRegionFromHost("abc123.execute-api.my-cd-1.localhost:4566"));
+ }
+
private static HttpHeaders stubHeaders(String authorizationValue) {
return new HttpHeaders() {
@Override public List<String> getRequestHeader(String name) {
diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2DescribeRegionsIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2DescribeRegionsIntegrationTest.java
new file mode 100644
index 0000000000..46709f3a60
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2DescribeRegionsIntegrationTest.java
@@ -0,0 +1,90 @@
+package io.github.hectorvent.floci.services.ec2;
+
+import io.github.hectorvent.floci.testing.PartitionMatrix;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.response.Response;
+import io.restassured.specification.RequestSpecification;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static io.restassured.RestAssured.given;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * DescribeRegions follows the request's partition and AWS's opt-in model: by default only the
+ * regions enabled for the account (every non-opt-in region), all published regions with
+ * {@code AllRegions}, and the endpoints carry the partition's DNS suffix.
+ */
+@QuarkusTest
+class Ec2DescribeRegionsIntegrationTest {
+
+ private Response describeRegions(String region, String... params) {
+ RequestSpecification request = given()
+ .header("Authorization", PartitionMatrix.sigV4Auth(region, "ec2"))
+ .formParam("Action", "DescribeRegions")
+ .formParam("Version", "2016-11-15");
+ for (int i = 0; i + 1 < params.length; i += 2) {
+ request = request.formParam(params[i], params[i + 1]);
+ }
+ return request.when().post("/").then().statusCode(200).contentType("application/xml")
+ .extract().response();
+ }
+
+ @Test
+ void commercialDefaultListsOnlyEnabledRegionsWithCommercialEndpoints() {
+ Response response = describeRegions("us-east-1");
+ List<String> names = response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionName");
+ List<String> statuses = response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.optInStatus");
+ List<String> endpoints = response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionEndpoint");
+
+ assertEquals(17, names.size(), "the commercial regions that need no opt-in: " + names);
+ assertTrue(names.contains("us-east-1"));
+ assertTrue(names.contains("eu-north-1"));
+ assertFalse(names.contains("ap-east-1"), "opt-in regions are hidden until AllRegions is set");
+ assertFalse(names.contains("cn-north-1"));
+ assertTrue(statuses.stream().allMatch("opt-in-not-required"::equals), statuses.toString());
+ assertTrue(endpoints.contains("ec2.us-east-1.amazonaws.com"), endpoints.toString());
+ }
+
+ @Test
+ void allRegionsIncludesOptInRegionsAsNotOptedIn() {
+ Response response = describeRegions("us-east-1", "AllRegions", "true");
+ List<String> names = response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionName");
+ assertEquals(34, names.size(), names.toString());
+ int hongKong = names.indexOf("ap-east-1");
+ assertTrue(hongKong >= 0, names.toString());
+ assertEquals("not-opted-in",
+ response.xmlPath().getString("DescribeRegionsResponse.regionInfo.item[" + hongKong + "].optInStatus"));
+ int virginia = names.indexOf("us-east-1");
+ assertEquals("opt-in-not-required",
+ response.xmlPath().getString("DescribeRegionsResponse.regionInfo.item[" + virginia + "].optInStatus"));
+ }
+
+ @Test
+ void regionNamesFilterReturnsTheNamedRegionsWhetherOrNotEnabled() {
+ Response response = describeRegions("us-east-1", "RegionName.1", "ap-east-1", "RegionName.2", "us-west-2");
+ List<String> names = response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionName");
+ assertEquals(List.of("ap-east-1", "us-west-2"), names);
+ }
+
+ @Test
+ void aChinaSignedRequestListsTheChinaPartition() {
+ Response response = describeRegions("cn-north-1");
+ assertEquals(List.of("cn-north-1", "cn-northwest-1"),
+ response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionName"));
+ assertEquals(List.of("ec2.cn-north-1.amazonaws.com.cn", "ec2.cn-northwest-1.amazonaws.com.cn"),
+ response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionEndpoint"));
+ }
+
+ @Test
+ void aGovCloudSignedRequestListsGovCloudWithTheCommercialSuffix() {
+ Response response = describeRegions("us-gov-west-1");
+ assertEquals(List.of("us-gov-east-1", "us-gov-west-1"),
+ response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionName"));
+ assertEquals(List.of("ec2.us-gov-east-1.amazonaws.com", "ec2.us-gov-west-1.amazonaws.com"),
+ response.xmlPath().getList("DescribeRegionsResponse.regionInfo.item.regionEndpoint"));
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/services/eventbridge/EventBridgeSchedulerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/eventbridge/EventBridgeSchedulerIntegrationTest.java
index ac7ccd7f8f..1b47271b33 100644
--- a/src/test/java/io/github/hectorvent/floci/services/eventbridge/EventBridgeSchedulerIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/eventbridge/EventBridgeSchedulerIntegrationTest.java
@@ -296,6 +296,8 @@ class EventBridgeSchedulerIntegrationTest {
@Override
public String defaultAccountId() { return ACCOUNT; }
@Override
+ public PartitionsConfig partitions() { return Optional::empty; }
+ @Override
public Optional<String> aiMockConfigFile() { return Optional.empty(); }
@Override
public StorageConfig storage() { return null; }
diff --git a/src/test/java/io/github/hectorvent/floci/testing/PartitionCleanup.java b/src/test/java/io/github/hectorvent/floci/testing/PartitionCleanup.java
new file mode 100644
index 0000000000..cf8e3563e7
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/testing/PartitionCleanup.java
@@ -0,0 +1,46 @@
+package io.github.hectorvent.floci.testing;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+/**
+ * Deletes what a test created in a non-commercial scope, in reverse order, after each test.
+ * The {@code @QuarkusTest} emulator is shared by every test class, and a resource left behind
+ * under {@code cn-north-1} shows up in every later cross-region listing (ResourceExplorer scans
+ * all resources), so a test that signs a foreign partition registers each create here.
+ *
+ * <pre>{@code
+ * @RegisterExtension
+ * final PartitionCleanup cleanup = new PartitionCleanup();
+ * ...
+ * createTable(region, name);
+ * cleanup.register(() -> deleteTable(region, name));
+ * }</pre>
+ *
+ * A failing cleanup never fails the test: it is reported on stderr so the leak is visible and
+ * the assertion that actually failed stays the headline.
+ */
+public final class PartitionCleanup implements AfterEachCallback {
+
+ private final Deque<Runnable> actions = new ArrayDeque<>();
+
+ public void register(Runnable action) {
+ actions.push(action);
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) {
+ while (!actions.isEmpty()) {
+ Runnable action = actions.pop();
+ try {
+ action.run();
+ } catch (RuntimeException e) {
+ System.err.println("PartitionCleanup: cleanup step failed after "
+ + context.getDisplayName() + ": " + e);
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/testing/PartitionMatrix.java b/src/test/java/io/github/hectorvent/floci/testing/PartitionMatrix.java
new file mode 100644
index 0000000000..c3848207e7
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/testing/PartitionMatrix.java
@@ -0,0 +1,79 @@
+package io.github.hectorvent.floci.testing;
+
+import io.github.hectorvent.floci.core.common.AwsArnUtils;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+
+import java.util.List;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * One representative region per AWS partition, for tests that assert partition-dependent
+ * behaviour (ARN partition segments, DNS suffixes, signing scopes). Tests that are not about
+ * partitions keep their {@code us-east-1} fixtures; nothing here is meant to rewrite them.
+ */
+public final class PartitionMatrix {
+
+ public record PartitionCase(String partition, String region, String dnsSuffix) {
+ @Override
+ public String toString() {
+ return partition + " (" + region + ")";
+ }
+ }
+
+ public static final String ACCOUNT = "000000000000";
+
+ private static final List<PartitionCase> ALL = List.of(
+ new PartitionCase("aws", "us-east-1", "amazonaws.com"),
+ new PartitionCase("aws-cn", "cn-north-1", "amazonaws.com.cn"),
+ new PartitionCase("aws-us-gov", "us-gov-west-1", "amazonaws.com"),
+ new PartitionCase("aws-iso", "us-iso-east-1", "c2s.ic.gov"),
+ new PartitionCase("aws-iso-b", "us-isob-east-1", "sc2s.sgov.gov"),
+ new PartitionCase("aws-iso-e", "eu-isoe-west-1", "cloud.adc-e.uk"),
+ new PartitionCase("aws-iso-f", "us-isof-south-1", "csp.hci.ic.gov"),
+ new PartitionCase("aws-eusc", "eusc-de-east-1", "amazonaws.eu"));
+
+ private PartitionMatrix() {
+ }
+
+ public static List<PartitionCase> all() {
+ return ALL;
+ }
+
+ /** For {@code @MethodSource("io.github.hectorvent.floci.testing.PartitionMatrix#cases")}. */
+ public static Stream<PartitionCase> cases() {
+ return ALL.stream();
+ }
+
+ /** A SigV4 Authorization header whose credential scope signs {@code region} for {@code service}. */
+ public static String sigV4Auth(String region, String service) {
+ return "AWS4-HMAC-SHA256 Credential=AKID/20260215/" + region + "/" + service + "/aws4_request, "
+ + "SignedHeaders=host;x-amz-date;x-amz-security-token, Signature=abc";
+ }
+
+ /** A resolver for a deployment whose default region is the case's region. */
+ public static RegionResolver regionResolver(PartitionCase partitionCase) {
+ return new RegionResolver(partitionCase.region(), ACCOUNT);
+ }
+
+ /** Asserts {@code arn} is a regional ARN of the case's partition and region. */
+ public static void assertArnIn(PartitionCase partitionCase, String arn) {
+ AwsArnUtils.Arn parsed = AwsArnUtils.parse(arn);
+ assertEquals(partitionCase.partition(), parsed.partition(), "partition of " + arn);
+ assertEquals(partitionCase.region(), parsed.region(), "region of " + arn);
+ }
+
+ /** Asserts {@code arn} is a regionless ARN of the case's partition. */
+ public static void assertGlobalArnIn(PartitionCase partitionCase, String arn) {
+ AwsArnUtils.Arn parsed = AwsArnUtils.parse(arn);
+ assertEquals(partitionCase.partition(), parsed.partition(), "partition of " + arn);
+ assertEquals("", parsed.region(), "a global ARN carries no region: " + arn);
+ }
+
+ /** Asserts {@code host} ends with the case's DNS suffix. */
+ public static void assertHostIn(PartitionCase partitionCase, String host) {
+ assertEquals(true, host.endsWith("." + partitionCase.dnsSuffix()),
+ host + " should end with ." + partitionCase.dnsSuffix());
+ }
+}
diff --git a/tools/aws/regen_partitions.py b/tools/aws/regen_partitions.py
new file mode 100644
index 0000000000..4a83113ccb
--- /dev/null
+++ b/tools/aws/regen_partitions.py
@@ -0,0 +1,269 @@
+#!/usr/bin/env python3
+"""Regenerate src/main/resources/aws/partitions.json from AWS's published partition data.
+
+Floci serves every AWS partition, and the Java side (`AwsPartitions`) reads one vendored
+file for all of it: partition ids, DNS suffixes, region lists, the `<partition>-global`
+pseudo-regions, which services each partition offers and which of them have a partition-wide
+endpoint with its signing region. Nothing in that file is hand-typed; this script derives it
+from two sources and a rule:
+
+- botocore's `partitions.json` and `endpoints.json` (MIT, https://github.com/boto/botocore),
+ the same data every AWS SDK resolves endpoints from. Located, in order, at `--botocore-data`,
+ the `local/aws/botocore` checkout (the reference corpus everything else in this repo is
+ grounded on), then the installed `botocore` package, which `requirements.txt` pins to the
+ version the vendored file was generated from so CI regenerates the same bytes.
+- The AWS CDK's `region-info/lib/aws-entities.ts` (Apache-2.0), whose ordered region list
+ carries two rule markers: regions before `RULE_S3_WEBSITE_REGIONAL_SUBDOMAIN` use the
+ legacy `s3-website-<region>` endpoint form, and commercial regions after
+ `RULE_CLASSIC_PARTITION_BECOMES_OPT_IN` are opt-in (DescribeRegions omits them by default).
+ botocore publishes neither fact. Read from `--cdk` or `local/aws/aws-cdk`; when the checkout
+ is absent (CI), the two flags are carried over from the existing output file, and a region
+ with nothing to carry is an error rather than a guess.
+
+Run from anywhere in the repo:
+ python3 tools/aws/regen_partitions.py # rewrite the vendored file in place
+ python3 tools/aws/regen_partitions.py --check # exit 1 when the vendored file is stale
+"""
+from __future__ import annotations
+
+import argparse
+import importlib
+import json
+import re
+import sys
+from pathlib import Path
+
+REPO_ROOT = Path(__file__).resolve().parents[2]
+OUTPUT = REPO_ROOT / "src/main/resources/aws/partitions.json"
+LOCAL_BOTOCORE_DATA = REPO_ROOT / "local/aws/botocore/botocore/data"
+LOCAL_CDK = REPO_ROOT / "local/aws/aws-cdk"
+CDK_ENTITIES = "packages/aws-cdk-lib/region-info/lib/aws-entities.ts"
+
+RULE_S3_WEBSITE = "RULE_S3_WEBSITE_REGIONAL_SUBDOMAIN"
+RULE_OPT_IN = "RULE_CLASSIC_PARTITION_BECOMES_OPT_IN"
+COMMERCIAL = "aws"
+
+ENTITY_REGION_RE = re.compile(r"^\s*'([a-z0-9-]+)',")
+ENTITY_RULE_RE = re.compile(r"^\s*(RULE_[A-Z0-9_]+),")
+
+
+# --------------------------------------------------------------------------- #
+# Sources
+# --------------------------------------------------------------------------- #
+def resolve_botocore_data(explicit: Path | None) -> tuple[Path, str]:
+ """The botocore data directory to read and a provenance label for it."""
+ if explicit is not None:
+ return explicit, f"--botocore-data {explicit}"
+ if (LOCAL_BOTOCORE_DATA / "partitions.json").exists():
+ return LOCAL_BOTOCORE_DATA, f"botocore {local_botocore_version()} (local/aws/botocore)"
+ try:
+ botocore = importlib.import_module("botocore")
+ data = Path(botocore.__file__).resolve().parent / "data"
+ if (data / "partitions.json").exists():
+ return data, f"botocore {botocore.__version__} (installed package)"
+ except ImportError:
+ pass
+ raise SystemExit("error: no botocore data found; check out local/aws/botocore, pass --botocore-data, "
+ "or pip install -r tools/aws/requirements.txt")
+
+
+def local_botocore_version() -> str:
+ init = LOCAL_BOTOCORE_DATA.parent / "__init__.py"
+ if init.exists():
+ match = re.search(r"__version__\s*=\s*'([^']+)'", init.read_text(encoding="utf-8"))
+ if match:
+ return match.group(1)
+ return "unknown"
+
+
+def load_json(path: Path) -> dict:
+ with path.open(encoding="utf-8") as handle:
+ return json.load(handle)
+
+
+def parse_cdk_entities(text: str) -> list[str]:
+ """The ordered `AWS_REGIONS_AND_RULES` entries: region ids and RULE_ markers, in file order."""
+ entries: list[str] = []
+ inside = False
+ for line in text.splitlines():
+ if "AWS_REGIONS_AND_RULES" in line and "=" in line and "[" in line:
+ inside = True
+ continue
+ if not inside:
+ continue
+ if line.strip().startswith("];"):
+ break
+ region = ENTITY_REGION_RE.match(line)
+ if region:
+ entries.append(region.group(1))
+ continue
+ rule = ENTITY_RULE_RE.match(line)
+ if rule:
+ entries.append(rule.group(1))
+ if RULE_S3_WEBSITE not in entries or RULE_OPT_IN not in entries:
+ raise ValueError("aws-entities.ts: AWS_REGIONS_AND_RULES lacks the two rule markers")
+ return entries
+
+
+def cdk_flags(entries: list[str], region: str, partition: str) -> tuple[bool, bool]:
+ """(optIn, s3WebsiteDashForm) exactly as CDK's generate-static-data.ts derives them.
+
+ `before(region, rule)` is false for a region the list does not know, so an unlisted
+ region is never dash-form and, in the commercial partition, is opt-in.
+ """
+ website_rule = entries.index(RULE_S3_WEBSITE)
+ opt_in_rule = entries.index(RULE_OPT_IN)
+ try:
+ index = entries.index(region)
+ except ValueError:
+ index = -1
+ before_website = index != -1 and index < website_rule
+ before_opt_in = index != -1 and index < opt_in_rule
+ opt_in = partition == COMMERCIAL and not before_opt_in
+ return opt_in, before_website
+
+
+# --------------------------------------------------------------------------- #
+# Generation
+# --------------------------------------------------------------------------- #
+def build(partitions_doc: dict, endpoints_doc: dict, entities: list[str] | None,
+ carried: dict | None, provenance: str) -> dict:
+ endpoint_partitions = {p["partition"]: p for p in endpoints_doc["partitions"]}
+ carried_flags = {}
+ for partition in (carried or {}).get("partitions", []):
+ for region in partition.get("regions", []):
+ carried_flags[region["id"]] = (bool(region.get("optIn")), bool(region.get("s3WebsiteDashForm")))
+
+ result_partitions = []
+ for meta in partitions_doc["partitions"]:
+ partition_id = meta["id"]
+ outputs = meta["outputs"]
+ endpoints_partition = endpoint_partitions.get(partition_id)
+ if endpoints_partition is None:
+ raise ValueError(f"endpoints.json has no partition {partition_id}")
+ pseudo = f"{partition_id}-global"
+ descriptions = {}
+ for source in (meta.get("regions", {}), endpoints_partition.get("regions", {})):
+ for region_id, info in source.items():
+ if region_id == pseudo:
+ continue
+ descriptions.setdefault(region_id, info.get("description", ""))
+ regions = []
+ for region_id in sorted(descriptions):
+ if entities is not None:
+ opt_in, dash = cdk_flags(entities, region_id, partition_id)
+ elif region_id in carried_flags:
+ opt_in, dash = carried_flags[region_id]
+ else:
+ raise ValueError(f"{region_id}: no aws-cdk checkout to derive optIn/s3WebsiteDashForm from and "
+ f"nothing to carry over from {OUTPUT.name}; run with local/aws/aws-cdk present")
+ regions.append({
+ "id": region_id,
+ "description": descriptions[region_id],
+ "optIn": opt_in,
+ "s3WebsiteDashForm": dash,
+ })
+ services = endpoints_partition.get("services", {})
+ global_services = {}
+ for service_key in sorted(services):
+ service = services[service_key]
+ partition_endpoint = service.get("partitionEndpoint")
+ if not partition_endpoint:
+ continue
+ endpoint = service.get("endpoints", {}).get(partition_endpoint, {})
+ hostname = endpoint.get("hostname") or (
+ endpoints_partition["defaults"]["hostname"]
+ .replace("{service}", service_key)
+ .replace("{region}", partition_endpoint)
+ .replace("{dnsSuffix}", outputs["dnsSuffix"]))
+ signing_region = endpoint.get("credentialScope", {}).get("region") or outputs["implicitGlobalRegion"]
+ global_services[service_key] = {
+ "hostname": hostname,
+ "signingRegion": signing_region,
+ "regionalized": service.get("isRegionalized", True) is not False,
+ }
+ result_partitions.append({
+ "id": partition_id,
+ "name": endpoints_partition.get("partitionName", partition_id),
+ "dnsSuffix": outputs["dnsSuffix"],
+ "dualStackDnsSuffix": outputs["dualStackDnsSuffix"],
+ "implicitGlobalRegion": outputs["implicitGlobalRegion"],
+ "regionRegex": meta["regionRegex"],
+ "globalPseudoRegion": pseudo if pseudo in meta.get("regions", {}) else None,
+ "supportsDualStack": bool(outputs.get("supportsDualStack", False)),
+ "supportsFips": bool(outputs.get("supportsFIPS", False)),
+ "regions": regions,
+ "services": sorted(services),
+ "globalServices": global_services,
+ })
+ result_partitions.sort(key=lambda p: (p["id"] != COMMERCIAL, p["id"]))
+ return {
+ "_source": {
+ "generator": "tools/aws/regen_partitions.py",
+ "botocore": provenance,
+ "partitionsJsonVersion": partitions_doc.get("version"),
+ "endpointsJsonVersion": endpoints_doc.get("version"),
+ "regionFlags": "aws-cdk region-info/lib/aws-entities.ts rules" if entities is not None
+ else "carried over from the previous file (no aws-cdk checkout)",
+ },
+ "partitions": result_partitions,
+ }
+
+
+def render(document: dict) -> str:
+ return json.dumps(document, indent=2, ensure_ascii=False) + "\n"
+
+
+def generate(botocore_data: Path, provenance: str, cdk_root: Path | None, existing: Path) -> dict:
+ partitions_doc = load_json(botocore_data / "partitions.json")
+ endpoints_doc = load_json(botocore_data / "endpoints.json")
+ entities = None
+ if cdk_root is not None and (cdk_root / CDK_ENTITIES).exists():
+ entities = parse_cdk_entities((cdk_root / CDK_ENTITIES).read_text(encoding="utf-8"))
+ carried = load_json(existing) if existing.exists() else None
+ return build(partitions_doc, endpoints_doc, entities, carried, provenance)
+
+
+def main(argv: list[str] | None = None) -> int:
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ parser.add_argument("--check", action="store_true", help="exit 1 when the vendored file differs from a fresh generation")
+ parser.add_argument("--botocore-data", type=Path, help="botocore data directory (partitions.json, endpoints.json)")
+ parser.add_argument("--cdk", type=Path, default=LOCAL_CDK, help="aws-cdk checkout root (default: local/aws/aws-cdk)")
+ parser.add_argument("--output", type=Path, default=OUTPUT, help=argparse.SUPPRESS)
+ args = parser.parse_args(argv)
+
+ botocore_data, provenance = resolve_botocore_data(args.botocore_data)
+ document = generate(botocore_data, provenance, args.cdk, args.output)
+ rendered = render(document)
+ rel = args.output.relative_to(REPO_ROOT) if args.output.is_relative_to(REPO_ROOT) else args.output
+
+ if args.check:
+ current = args.output.read_text(encoding="utf-8") if args.output.exists() else ""
+ if strip_source(current) != strip_source(rendered):
+ previous = json.loads(current).get("_source", {}).get("botocore", "unknown") if current.strip() else "nothing"
+ print(f"error: {rel} (generated from {previous}) differs from a fresh generation against {provenance}.")
+ print(" Run 'make aws-data-sync' and commit the result; if the two botocore versions differ, "
+ "align tools/aws/requirements.txt with the checkout first.")
+ return 1
+ print(f"{rel} is up to date ({len(document['partitions'])} partitions, "
+ f"{sum(len(p['regions']) for p in document['partitions'])} regions)")
+ return 0
+
+ args.output.parent.mkdir(parents=True, exist_ok=True)
+ args.output.write_text(rendered, encoding="utf-8")
+ print(f"wrote {rel} from {provenance}: {len(document['partitions'])} partitions, "
+ f"{sum(len(p['regions']) for p in document['partitions'])} regions")
+ return 0
+
+
+def strip_source(text: str) -> str:
+ """The document without its provenance block, so the check compares data, not labels."""
+ if not text.strip():
+ return ""
+ document = json.loads(text)
+ document.pop("_source", None)
+ return json.dumps(document, sort_keys=True)
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/tools/aws/requirements.txt b/tools/aws/requirements.txt
new file mode 100644
index 0000000000..fe9ad4e9f1
--- /dev/null
+++ b/tools/aws/requirements.txt
@@ -0,0 +1,2 @@
+botocore==1.43.98
+pytest>=7.0
diff --git a/tools/aws/test_regen_partitions.py b/tools/aws/test_regen_partitions.py
new file mode 100644
index 0000000000..31d083e6fe
--- /dev/null
+++ b/tools/aws/test_regen_partitions.py
@@ -0,0 +1,281 @@
+"""Tests for regen_partitions.
+
+Run with: pytest tools/aws -q (or: make aws-data-test)
+"""
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+
+import regen_partitions as r
+
+
+ENTITIES = """
+export const AWS_REGIONS_AND_RULES: readonly (string | symbol)[] = [
+ 'us-east-1', // US East (N. Virginia)
+ 'us-gov-west-1', // AWS GovCloud (US-West)
+ RULE_S3_WEBSITE_REGIONAL_SUBDOMAIN,
+ 'cn-north-1', // China (Beijing)
+ 'eu-north-1', // Europe (Stockholm)
+ RULE_CLASSIC_PARTITION_BECOMES_OPT_IN,
+ 'ap-east-1', // Asia Pacific (Hong Kong)
+ 'cn-northwest-1', // China (Ningxia)
+];
+
+export const AWS_REGIONS = AWS_REGIONS_AND_RULES.filter((x) => typeof x === 'string').sort();
+"""
+
+PARTITIONS = {
+ "partitions": [
+ {
+ "id": "aws-cn",
+ "outputs": {"dnsSuffix": "amazonaws.com.cn", "dualStackDnsSuffix": "api.amazonwebservices.com.cn",
+ "implicitGlobalRegion": "cn-northwest-1", "name": "aws-cn",
+ "supportsDualStack": True, "supportsFIPS": True},
+ "regionRegex": "^cn\\-\\w+\\-\\d+$",
+ "regions": {"aws-cn-global": {"description": "aws-cn global region"},
+ "cn-north-1": {"description": "China (Beijing)"},
+ "cn-northwest-1": {"description": "China (Ningxia)"}},
+ },
+ {
+ "id": "aws",
+ "outputs": {"dnsSuffix": "amazonaws.com", "dualStackDnsSuffix": "api.aws",
+ "implicitGlobalRegion": "us-east-1", "name": "aws",
+ "supportsDualStack": True, "supportsFIPS": True},
+ "regionRegex": "^(us|eu|ap)\\-\\w+\\-\\d+$",
+ "regions": {"aws-global": {"description": "aws global region"},
+ "us-east-1": {"description": "US East (N. Virginia)"},
+ "eu-north-1": {"description": "Europe (Stockholm)"}},
+ },
+ {
+ "id": "aws-eusc",
+ "outputs": {"dnsSuffix": "amazonaws.eu", "dualStackDnsSuffix": "api.amazonwebservices.eu",
+ "implicitGlobalRegion": "eusc-de-east-1", "name": "aws-eusc",
+ "supportsDualStack": True, "supportsFIPS": True},
+ "regionRegex": "^eusc\\-(de)\\-\\w+\\-\\d+$",
+ "regions": {"eusc-de-east-1": {"description": "EU (Germany)"}},
+ },
+ ],
+ "version": "1.1",
+}
+
+ENDPOINTS = {
+ "partitions": [
+ {
+ "partition": "aws",
+ "partitionName": "AWS Standard",
+ "dnsSuffix": "amazonaws.com",
+ "defaults": {"hostname": "{service}.{region}.{dnsSuffix}"},
+ "regions": {"us-east-1": {"description": "US East (N. Virginia)"},
+ "eu-north-1": {"description": "Europe (Stockholm)"},
+ "ap-east-1": {"description": "Asia Pacific (Hong Kong)"}},
+ "services": {
+ "iam": {"endpoints": {"aws-global": {"credentialScope": {"region": "us-east-1"},
+ "hostname": "iam.amazonaws.com"}},
+ "isRegionalized": False, "partitionEndpoint": "aws-global"},
+ "sts": {"endpoints": {"aws-global": {"credentialScope": {"region": "us-east-1"},
+ "hostname": "sts.amazonaws.com"},
+ "us-east-1": {}},
+ "partitionEndpoint": "aws-global"},
+ "codecatalyst": {"endpoints": {"aws-global": {"hostname": "codecatalyst.global.api.aws"}},
+ "isRegionalized": False, "partitionEndpoint": "aws-global"},
+ "nohost": {"endpoints": {"aws-global": {"credentialScope": {"region": "us-east-1"}}},
+ "isRegionalized": False, "partitionEndpoint": "aws-global"},
+ "sqs": {"endpoints": {"us-east-1": {}}},
+ },
+ },
+ {
+ "partition": "aws-cn",
+ "partitionName": "AWS China",
+ "dnsSuffix": "amazonaws.com.cn",
+ "defaults": {"hostname": "{service}.{region}.{dnsSuffix}"},
+ "regions": {"cn-north-1": {"description": "China (Beijing)"},
+ "cn-northwest-1": {"description": "China (Ningxia)"}},
+ "services": {
+ "iam": {"endpoints": {"aws-cn-global": {"credentialScope": {"region": "cn-north-1"},
+ "hostname": "iam.cn-north-1.amazonaws.com.cn"}},
+ "isRegionalized": False, "partitionEndpoint": "aws-cn-global"},
+ "sqs": {"endpoints": {"cn-north-1": {}}},
+ },
+ },
+ {
+ "partition": "aws-eusc",
+ "partitionName": "AWS EUSC",
+ "dnsSuffix": "amazonaws.eu",
+ "defaults": {"hostname": "{service}.{region}.{dnsSuffix}"},
+ "regions": {"eusc-de-east-1": {"description": "EU (Germany)"}},
+ "services": {"sqs": {"endpoints": {"eusc-de-east-1": {}}}},
+ },
+ ],
+ "version": 3,
+}
+
+
+def by_id(document: dict, partition_id: str) -> dict:
+ return next(p for p in document["partitions"] if p["id"] == partition_id)
+
+
+def region(partition: dict, region_id: str) -> dict:
+ return next(x for x in partition["regions"] if x["id"] == region_id)
+
+
+# --------------------------------------------------------------------------- #
+# CDK rules
+# --------------------------------------------------------------------------- #
+def test_parse_cdk_entities_keeps_file_order_with_rule_markers():
+ assert r.parse_cdk_entities(ENTITIES) == [
+ "us-east-1", "us-gov-west-1", r.RULE_S3_WEBSITE, "cn-north-1", "eu-north-1",
+ r.RULE_OPT_IN, "ap-east-1", "cn-northwest-1",
+ ]
+
+
+def test_parse_cdk_entities_requires_both_rules():
+ with pytest.raises(ValueError, match="rule markers"):
+ r.parse_cdk_entities("export const AWS_REGIONS_AND_RULES = [\n 'us-east-1',\n];\n")
+
+
[email protected]("region_id,partition,opt_in,dash", [
+ ("us-east-1", "aws", False, True),
+ ("us-gov-west-1", "aws-us-gov", False, True),
+ ("cn-north-1", "aws-cn", False, False),
+ ("eu-north-1", "aws", False, False),
+ ("ap-east-1", "aws", True, False),
+ ("cn-northwest-1", "aws-cn", False, False),
+ ("eu-nowhere-9", "aws", True, False),
+ ("cn-nowhere-9", "aws-cn", False, False),
+])
+def test_cdk_flags_follow_the_two_rules(region_id, partition, opt_in, dash):
+ entries = r.parse_cdk_entities(ENTITIES)
+ assert r.cdk_flags(entries, region_id, partition) == (opt_in, dash)
+
+
+# --------------------------------------------------------------------------- #
+# Build
+# --------------------------------------------------------------------------- #
+def test_build_puts_the_commercial_partition_first_then_sorts_by_id():
+ document = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test")
+ assert [p["id"] for p in document["partitions"]] == ["aws", "aws-cn", "aws-eusc"]
+
+
+def test_build_unions_regions_from_both_files_and_excludes_the_pseudo_region():
+ document = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test")
+ aws = by_id(document, "aws")
+ assert [x["id"] for x in aws["regions"]] == ["ap-east-1", "eu-north-1", "us-east-1"]
+ assert region(aws, "ap-east-1")["description"] == "Asia Pacific (Hong Kong)"
+ assert aws["globalPseudoRegion"] == "aws-global"
+ assert by_id(document, "aws-eusc")["globalPseudoRegion"] is None
+
+
+def test_build_carries_partition_outputs_and_names():
+ document = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test")
+ cn = by_id(document, "aws-cn")
+ assert cn["name"] == "AWS China"
+ assert cn["dnsSuffix"] == "amazonaws.com.cn"
+ assert cn["dualStackDnsSuffix"] == "api.amazonwebservices.com.cn"
+ assert cn["implicitGlobalRegion"] == "cn-northwest-1"
+ assert cn["regionRegex"] == "^cn\\-\\w+\\-\\d+$"
+ assert cn["supportsDualStack"] is True and cn["supportsFips"] is True
+ assert cn["services"] == ["iam", "sqs"]
+
+
+def test_build_derives_global_services_from_partition_endpoint():
+ document = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test")
+ aws = by_id(document, "aws")["globalServices"]
+ assert aws["iam"] == {"hostname": "iam.amazonaws.com", "signingRegion": "us-east-1", "regionalized": False}
+ # isRegionalized absent means regional endpoints exist beside the global host (STS)
+ assert aws["sts"] == {"hostname": "sts.amazonaws.com", "signingRegion": "us-east-1", "regionalized": True}
+ # no credentialScope: the partition's implicit global region signs
+ assert aws["codecatalyst"]["signingRegion"] == "us-east-1"
+ # no hostname: the partition's default template with the endpoint key as region
+ assert aws["nohost"]["hostname"] == "nohost.aws-global.amazonaws.com"
+ assert "sqs" not in aws
+ assert by_id(document, "aws-cn")["globalServices"]["iam"]["signingRegion"] == "cn-north-1"
+ assert by_id(document, "aws-eusc")["globalServices"] == {}
+
+
+def test_build_applies_opt_in_and_dash_form_flags():
+ document = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test")
+ aws = by_id(document, "aws")
+ assert region(aws, "us-east-1") == {"id": "us-east-1", "description": "US East (N. Virginia)",
+ "optIn": False, "s3WebsiteDashForm": True}
+ assert region(aws, "ap-east-1")["optIn"] is True
+ assert region(by_id(document, "aws-cn"), "cn-north-1")["optIn"] is False
+
+
+def test_build_without_cdk_carries_flags_from_the_previous_file():
+ with_cdk = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test")
+ carried = r.build(PARTITIONS, ENDPOINTS, None, with_cdk, "test")
+ assert r.strip_source(r.render(carried)) == r.strip_source(r.render(with_cdk))
+ assert "carried over" in carried["_source"]["regionFlags"]
+
+
+def test_build_without_cdk_refuses_a_region_it_cannot_carry():
+ with pytest.raises(ValueError, match="no aws-cdk checkout"):
+ r.build(PARTITIONS, ENDPOINTS, None, {"partitions": []}, "test")
+
+
+def test_build_refuses_a_partition_missing_from_endpoints_json():
+ endpoints = {"partitions": [p for p in ENDPOINTS["partitions"] if p["partition"] != "aws-eusc"], "version": 3}
+ with pytest.raises(ValueError, match="aws-eusc"):
+ r.build(PARTITIONS, endpoints, r.parse_cdk_entities(ENTITIES), None, "test")
+
+
+# --------------------------------------------------------------------------- #
+# CLI
+# --------------------------------------------------------------------------- #
+def write_sources(tmp_path: Path) -> tuple[Path, Path]:
+ data = tmp_path / "botocore-data"
+ data.mkdir()
+ (data / "partitions.json").write_text(json.dumps(PARTITIONS))
+ (data / "endpoints.json").write_text(json.dumps(ENDPOINTS))
+ cdk = tmp_path / "cdk"
+ entities = cdk / r.CDK_ENTITIES
+ entities.parent.mkdir(parents=True)
+ entities.write_text(ENTITIES)
+ return data, cdk
+
+
+def test_cli_writes_then_reports_up_to_date_then_detects_drift(tmp_path, capsys):
+ data, cdk = write_sources(tmp_path)
+ output = tmp_path / "out" / "partitions.json"
+ common = ["--botocore-data", str(data), "--cdk", str(cdk), "--output", str(output)]
+
+ assert r.main(["--check"] + common) == 1
+ assert "differs from a fresh generation" in capsys.readouterr().out
+
+ assert r.main(common) == 0
+ assert "3 partitions, 6 regions" in capsys.readouterr().out
+ document = json.loads(output.read_text())
+ assert document["_source"]["generator"] == "tools/aws/regen_partitions.py"
+ assert document["_source"]["partitionsJsonVersion"] == "1.1"
+ assert document["_source"]["endpointsJsonVersion"] == 3
+
+ assert r.main(["--check"] + common) == 0
+ assert "is up to date" in capsys.readouterr().out
+
+ (data / "endpoints.json").write_text(json.dumps({
+ **ENDPOINTS,
+ "partitions": [dict(p, partitionName="renamed") if p["partition"] == "aws" else p for p in ENDPOINTS["partitions"]],
+ }))
+ assert r.main(["--check"] + common) == 1
+ assert "make aws-data-sync" in capsys.readouterr().out
+
+
+def test_cli_check_ignores_provenance_differences(tmp_path):
+ data, cdk = write_sources(tmp_path)
+ output = tmp_path / "partitions.json"
+ common = ["--botocore-data", str(data), "--cdk", str(cdk), "--output", str(output)]
+ assert r.main(common) == 0
+ document = json.loads(output.read_text())
+ document["_source"]["botocore"] = "some other label"
+ output.write_text(json.dumps(document))
+ assert r.main(["--check"] + common) == 0
+
+
+def test_repo_file_matches_the_local_checkout_when_present():
+ if not (r.LOCAL_BOTOCORE_DATA / "partitions.json").exists() or not (r.LOCAL_CDK / r.CDK_ENTITIES).exists():
+ pytest.skip("local/aws checkouts not present")
+ document = r.generate(r.LOCAL_BOTOCORE_DATA, "test", r.LOCAL_CDK, r.OUTPUT)
+ assert r.strip_source(r.render(document)) == r.strip_source(r.OUTPUT.read_text(encoding="utf-8"))
diff --git a/tools/partition/baseline.tsv b/tools/partition/baseline.tsv
index 1e23f4d3ef..f61aa799f6 100644
--- a/tools/partition/baseline.tsv
+++ b/tools/partition/baseline.tsv
@@ -35,6 +35,7 @@ arn-literal src/main/java/io/github/hectorvent/floci/services/emrserverless/EmrS
arn-literal src/main/java/io/github/hectorvent/floci/services/guardduty/GuardDutyService.java 1
arn-literal src/main/java/io/github/hectorvent/floci/services/iam/AwsManagedPolicies.java 1
arn-literal src/main/java/io/github/hectorvent/floci/services/iam/IamPolicyEvaluator.java 4
+arn-literal src/main/java/io/github/hectorvent/floci/services/iam/IamService.java 1
arn-literal src/main/java/io/github/hectorvent/floci/services/iam/SAMLAssertionVerifier.java 2
arn-literal src/main/java/io/github/hectorvent/floci/services/iam/SAMLProviderService.java 2
arn-literal src/main/java/io/github/hectorvent/floci/services/kinesisanalytics/KinesisAnalyticsV2JsonHandler.java 2
@@ -80,8 +81,10 @@ arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/apigateway/A
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreGatewayRuleService.java 3
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreToolsService.java 1
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/budgets/BudgetsService.java 2
+arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/ce/CostAnomalyService.java 1
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/controltower/ControlTowerControlService.java 1
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/controltower/ControlTowerService.java 1
+arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java 1
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/firehose/ProcessingConfigurationValidator.java 1
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/kms/KmsService.java 2
arn-regex-dialect src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java 1
@@ -112,7 +115,7 @@ dns-suffix src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTra
dns-suffix src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailService.java 5
dns-suffix src/main/java/io/github/hectorvent/floci/services/cognito/CognitoService.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/services/connect/ConnectService.java 1
-dns-suffix src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java 1
+dns-suffix src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/services/eks/EksOidcService.java 2
dns-suffix src/main/java/io/github/hectorvent/floci/services/eks/EksPodIdentityCredentialsController.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/services/eks/EksPodIdentityWebhook.java 2
@@ -128,7 +131,6 @@ dns-suffix src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/services/s3/S3VirtualHostFilter.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/services/signin/SigninService.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/services/ssoportal/SsoPortalService.java 1
-dns-suffix src/main/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutor.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/services/verifiedpermissions/VerifiedPermissionsService.java 1
dns-suffix src/main/java/io/github/hectorvent/floci/tools/ami/AmiImageTool.java 1
hosted-zone-id src/main/java/io/github/hectorvent/floci/services/apigateway/ApiGatewayService.java 2