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

P1 of the multi-partition initiative (#4272). tools/aws/regen_partitions.py
vendors botocore's partitions.json and endpoints.json (8 partitions, 46 regions,
the partition-wide endpoints with their signing regions) plus the CDK's opt-in
and S3 website rules into src/main/resources/aws/partitions.json, checked by
make aws-data-check. AwsPartition and AwsPartitions replace the hand-typed rules
behind AwsRegions; RequestContext carries the request's partition from its
SigV4 signing region; RegionResolver mints global ARNs in that partition and
buildArn routes a blank region there; floci.partitions.id pins the deployment's
partition behind a startup validator that refuses a contradiction with the
default region.

Behaviour a reviewer will see, all AWS-faithful: DescribeRegions follows the
request's partition and the opt-in model (17 commercial regions by default, all
34 with AllRegions=true, RegionName.N filters, endpoints on the partition's DNS
suffix); TLS SANs cover every published region; the EKS registry mirrors follow
the deployment partition's regions. The partition-literal baseline drops by two.

Part of #4272
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-09-24 10:33:05 -04:00
1 parent e73b80d5ee
commit 0dd080a46f
39 files changed
+3946 -152

No files matched your search

@@ -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
+2 -1
View File
@@ -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 |
+91
View File
@@ -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