Twelve startsWith("arn:") probes become AwsArnUtils.looksLikeArn. The SES tenant resource reader, the SWF tag region, the Verified Permissions Cognito user pool check (now AwsArnUtils.isArnFor) and the AppSync data source region read ARN fields with AwsArnUtils.parse and regionOrDefault instead of a split.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
Seven startsWith("arn:") probes become AwsArnUtils.looksLikeArn. RAM, the Resource Groups Tagging visibility check, the CloudWatch dashboards cross-account ARN and Service Catalog read ARN fields with AwsArnUtils.parse and regionOrDefault instead of a split; the dashboards ARN without its region is rebuilt as an AwsArnUtils.Arn.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
Ten startsWith("arn:") probes on name-or-ARN parameters become AwsArnUtils.looksLikeArn. DataSync's private arnRegion and arnAccountId copies are deleted in favour of AwsArnUtils.regionOrDefault and accountOrDefault, and its resource, Glue's resource and Redshift's integration source type are read with AwsArnUtils.parse instead of a split.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
The startsWith("arn:") probes in Lambda, Lambda MicroVMs and the API Gateway v2 quick-create target become AwsArnUtils.looksLikeArn. The runtime version ARN and the MicroVM image region read the region with AwsArnUtils.regionOrDefault instead of a split. LambdaTagController keeps its split, marked: Lambda reads the fourth field of any tag target, ARN or not, which IamRestRouteEnforcementIntegrationTest pins.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
The eleven startsWith("arn:") probes in EcsService, EcsContainerManager and EcsCfnProvisioner become AwsArnUtils.looksLikeArn, which is the same check, and the null guards it already makes are dropped.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* refactor(core): add AwsArnUtils.looksLikeArn for name-or-ARN parameters
A parameter that takes a name or an ARN, where AWS answers a malformed ARN with its own error, needs to treat any value starting arn: as an attempted ARN. isArn needs all six fields and would send arn:aws:rds down the name path, so the sites the earlier migration PRs left on purpose still probe with a hand-written startsWith. looksLikeArn is that probe, in one place, so the area PRs that follow can move them off the arn-probe baseline without changing the error a caller sees.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* refactor(rds,docdb,neptune,cloudformation): tell names from ARNs through AwsArnUtils
The startsWith("arn:") probes on name-or-ARN parameters in RDS, DocumentDB, Neptune, CloudFormation and the EC2 instance provisioner become AwsArnUtils.looksLikeArn, the same check, so a malformed ARN still gets the operation's own error. NeptuneQueryHandler reads a resource's region with AwsArnUtils.parse instead of a split.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* refactor(rds): read and check ARNs through AwsArnUtils
RdsQueryHandler read the region of an instance ARN and rebuilt its subnet
group ARN by splitting it; those now use regionOrDefault and parse, and the
service-local regionFromRdsArn copy is gone. Six startsWith("arn:") probes in
RdsService become isArn where the result is the same for every input: replica
link names Floci stored itself, the instance and cluster list filters, the
tag-resource region default and the cluster lookup by reference.
The seven other probes stay. They treat any value starting with arn: as an
attempted ARN, so a malformed one gets InvalidParameterValue (or its own not
found error); isArn would send it down the identifier path and change the
error.
No behaviour change. The partition baseline drops from 144 to 136.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* refactor(cloudformation): check ARNs through AwsArnUtils
Seven startsWith("arn:") probes become AwsArnUtils.isArn where the result is
the same for every input: the deleted-stack and live-stack lookups by ARN,
where a malformed ARN resolves to no stack either way; the change set ARN
check that only runs after resolveChangeSetName has rejected malformed ARNs;
and the Batch, Bedrock AgentCore and IAM policy provisioners' checks of
physical ids Floci minted itself.
The six other probes stay: DeleteChangeSet, DeleteStack, the change set name
resolver and the change set's stack lookup give a malformed ARN its own
ValidationError or no-op, and the EC2 instance and ECS provisioners read
template values, where isArn would change how an "arn:" value resolves.
No behaviour change. The partition baseline drops from 136 to 129.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
The docs tools, the partition gate and their registries each spelled
out src/main/java/io/github/hectorvent/floci/. tools/java_sources.py
now holds the package path, the tools import it, and services.yaml and
service_matrix.yaml list sources relative to the package root, so the
move to io.floci.aws changes one line here. A registry entry still in
the repo-relative form fails with a message naming the new form.
prefetch-images.sh finds TestImages.java by name.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
EKS minted its access entry, addon and pod identity association ARNs and the
STS assumed-role username by concatenating the parts of a split cluster or
principal ARN, and read account and region from the cluster ARN by splitting
it. Those now go through AwsArnUtils: parse for the fields, Arn.global for the
assumed-role ARN, and one childArn helper that keeps the cluster's partition,
region and account. The role ARN checks keep their conditions and errors.
No behaviour change. EKS no longer has any arn-concat or arn-split site, so
the partition baseline drops by 15.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
The partition-literal gate only saw ARNs that name a partition. Code that
builds, checks or cuts an ARN by hand names none, so it passed the gate while
bypassing the helpers that get every partition right, and the number of
startsWith("arn:") probes grew from 84 to 98 in two weeks.
Three code-scope categories join the per-file baseline:
- arn-concat: "arn:" + ..., except a pattern built from PARTITION_REGEX
- arn-probe: startsWith("arn:")
- arn-split: split(":") on a value named like an ARN
The baseline starts with today's 159 sites, so new ones fail and migrating
existing ones to AwsArnUtils shrinks it. AwsArnUtils's own formatter and
parser carry partition-literal escapes. PartitionSmokeInventoryTest also
counts a concatenated ARN as minting, and AGENTS.md names the categories.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* fix(efs): report the zone id EC2 reports for the same zone
EFS derived its own availability-zone id (use1-az1) by splitting the region
on hyphens, while EC2 publishes <region>-az<n> for subnets and zones, so a
mount target and its subnet disagreed. The abbreviation also only worked
for three-part regions: us-gov-west-1a and eusc-de-east-1a kept the whole
region. EFS now takes the id from the helper EC2 and VPC flow logs use.
Also drops an allowlist pattern for flow-log region abbreviations that
matches no source line since flow logs moved to the same helper.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* fix(ec2): give availability-zone ids AWS's shape, shared by EC2, flow logs and EFS
EC2 published <region>-az<n> as a zone id and EFS its own abbreviation, so
a mount target and its subnet disagreed and neither matched AWS in every
region. AvailabilityZoneIds in core.common now derives the id for all
three: AWS's short region prefix and -az<n> (use1-az1, apne1-az1,
usgw1-az1, cnn1-az1). The prefix rule is attested for the commercial, China
and GovCloud regions; AWS publishes no zone id for an ISO or EUSC region,
so those keep the whole region as the prefix instead of a guessed one.
Zone a is still az1, b az2, and so on: AWS maps names to ids per account,
which Floci does not model. CreateSubnet resolves AvailabilityZoneId in the
new shape and refuses the old one.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
The partition literal gate's dns-suffix pattern matched amazonaws.com but
not a Java regex that escapes its dots (amazonaws\\.com), so hand-written
host patterns escaped it. With the dots allowed to be escaped, the gate
found two on main:
- ECR's pull-through cache recognised an ecr upstream only on the
commercial and China suffixes, while Floci's own registry recognises an
ECR image URI in every partition. The upstream host pattern is now
built from AwsPartitions.dnsSuffixRegex() the same way.
- The console sign-in host pattern in SigninService has no published
non-commercial form, so it carries a partition-literal escape like the
console literals beside it.
* chore(core): gate comparisons of a partition with the literal "aws"
The five checks #4791 fixed compared a parsed ARN's partition with "aws", so
RDS, ElastiCache and RAM broke silently outside the commercial partition, and
make partition-check could not see them: a bare "aws" is not an arn:aws:
prefix. partition_literals.py gains a gated aws-partition-compare category,
scanned over the code with comments and text blocks blanked, that catches
"aws".equals(...), .equals("aws"), their equalsIgnoreCase forms and
Objects.equals with "aws". Run against main before #4791 it reports exactly
those five sites.
The three remaining uses compare an account, a command name and a reserved
SSM name prefix, not a partition, and are escaped with a reason. AGENTS.md
states the rule next to the other partition rules, so reviews flag it too.
The audit table sizes its columns to the longest category name.
Part of #4272.
* chore(core): end the Objects.equals match at its call and gate switch labels on "aws"
Greptile on #4892: the Objects.equals arm read past the call's closing
parenthesis, so foo(Objects.equals(a, b), "aws") matched a comparison that is
not there; each argument now allows one level of nested calls and the match
ends at the call's own parenthesis. And a switch on a partition branched on
"aws" without a match, so case labels naming "aws", alone or in a list, are
caught too. main has none, so no new escapes and the baseline stays empty.
* fix(core): mint every regionless ARN in its partition and gate blank-region Arn.of calls
Part of #4272 (P10a). Arn.of derives the partition from the region, so a
blank region always minted arn:aws:, and the partition literal gate could not
see it because it is a call shape, not a literal. Sixteen call sites did this,
and three gated literals were left:
- RdsSigV4Validator built the rds-db:connect resource as arn:aws:rds-db:, so a
China IAM policy naming arn:aws-cn:rds-db: never matched and IAM auth to an
RDS proxy was denied there.
- CloudFront, Organizations, Cost Explorer anomaly monitors and the SSO portal
role ARN now take the request's partition (RegionResolver injected).
- S3 bucket ARNs (event notifications, AWS::S3::Bucket Arn, Cost Explorer S3
usage) take the bucket's or the stack region's partition; the Lambda CFN
default role, the Kinesis ESM invokeIdentityArn, the EC2 launch template
CreatedBy and the SQS AddPermission root principal take their own region's.
- FlinkContainerManager's fallback key goes through Arn.of, and the
CloudFormation S3 TemplateURL host check accepts every partition's DNS suffix.
partition_literals.py gains a gated, code-scoped blank-region-arn category
(Arn.of with a "" or null region, comments excluded). The baseline is now
empty, so any new literal or blank-region mint fails Partition Literals.
* fix(core): scan blank-region Arn.of calls across lines and skip text blocks
Greptile on #4787: the blank-region-arn category ran per line, so a call whose
region argument sits on the next line escaped it, and text-block contents were
kept, so an example inside one would count as a call against the empty
baseline. code_text now blanks comments and text blocks over the whole source
and the code categories match across lines, reporting the line the call starts
on.
The bundled managed policy catalog is the commercial one, so
arn:aws-cn:iam::aws:policy/AdministratorAccess did not resolve and a China
deployment listed commercial ARNs. Every other partition's catalog is now
derived from the bundled data on first use and cached per partition: every
arn:aws: inside a document takes the partition, as AWS's SAM translator does
for managed policy ARNs (arn_generator.py), and the region-bearing
kms:ViaService hosts (s3.*.amazonaws.com) take the partition's DNS suffix.
Bare service principals and service-linked role paths are universal (#4633)
and are left alone, as is the ::aws:policy/ owner slot.
IamService resolves a managed policy under the partition its ARN names, so a
China ARN resolves under any signing scope, and ListPolicies lists the catalog
of the caller's partition.
Partition literal baseline 4 -> 3.
Part of #4272
* fix(core): service principals are universal in every partition; accept the legacy forms
A service principal is <service>.amazonaws.com in every partition, the rule the CDK applies
(region-info.ts, principals.ts). Floci now emits it through ServicePrincipals.of: generated trust
policies, SAM's Lambda permissions, CloudTrail's eventSource, service-linked role paths (Macie,
GuardDuty, Connect, Application Auto Scaling, RAM, SSO) and the Redshift COPY trust check.
Policies may still name a service in the per-partition form AWS accepted before
(elasticmapreduce.amazonaws.com.cn, logs.cn-north-1.amazonaws.com.cn, config.c2s.ic.gov), and AWS
still honours them. ServicePrincipals.canonical folds a published DNS suffix and a regional label
away, and the trust-policy evaluator and CreateServiceLinkedRole compare in that form, so either
spelling matches.
DescribeVpcEndpointServices now lists China's S3 interface service, cn.com.amazonaws.<region>.s3,
beside the com.amazonaws gateway one, each with its own type; where the names agree it stays one
service carrying both types.
Partition literal baseline 34 -> 4 occurrences. The web-identity and pod-identity audiences keep
their commercial literals, escaped for the STS phase.
Part of #4272
* fix(iam): put a legacy-named service-linked role under the universal principal
CreateServiceLinkedRole derived the role name from the universal principal but kept the caller's legacy spelling (es.amazonaws.com.cn) in the path and the trust policy. All three now use the universal principal, so the role lists under /aws-service-role/es.amazonaws.com/ like one created from the universal name.
ServicePrincipals.canonical no longer lower-cases: service-principal matching is exact and case-sensitive since #4555, and AWS matches principals case-sensitively, so only a suffix written the way AWS publishes it folds.
* feat(core): vendor the per-region hosted zones, SAML URLs and VPC endpoint prefixes
tools/aws/regen_region_facts.py transcribes the per-region and per-partition constants AWS publishes only as prose tables into src/main/resources/aws/region-facts.json: the Terraform provider's load balancer and S3 website hosted-zone maps, the CloudFront hosted zone per partition (cross-checked against the CDK), and the CDK's SAML sign-on URLs and VPC endpoint service-name exceptions. AwsRegionFacts serves them, as Optionals where a partition publishes nothing (the ISO and EUSC partitions have no hosted zones). make aws-data-check regenerates and compares where the local reference checkouts exist, and verifies the file's shape where they do not.
Behaviour this changes: network load balancers report their own hosted zone per region instead of the Application one, Classic and Application load balancers report their region's zone, API Gateway EDGE domains carry the CloudFront zone of their partition, SAML assertions are checked against the sign-on URL of the provider's partition, and the AWS-managed S3 and DynamoDB prefix lists carry the partition's service-name prefix.
Also carries the follow-ups from the #4494 review: bucketRegionForCreate cites the S3 model for the us-east-1 rules, docs/services/s3.md gains a Bucket Regions section, and the Marketplace files are gated per line with stated reasons instead of being allowlisted by path, so a new region literal there is caught.
Part of #4272
* fix(core): harden the region facts against restarts, partitions without CloudFront, and CI without sources
The source-free data check rejected real twelve-character hosted zone ids such as ap-southeast-1's NLB zone ZKVM4W9LS7TM, which failed the vendored-data job. It now accepts Route 53's id length range and checks substance: every partition has an entry whose VPC endpoint prefix is its reversed DNS suffix, every region is published in partitions.json, SAML URLs are https sign-on URLs, and unknown fields are refused.
Load balancers restored from storage take the hosted zone of their region and type again, so balancers stored before the per-region lookup stop reporting the old fixed zone. An EDGE API Gateway custom domain is refused where the partition has no CloudFront, since it would have no distribution zone to alias to. A customer prefix list may not take the prefix of the AWS-managed lists its region carries, cn.com.amazonaws. in China. The partitions doc now says which ISO hosted zones exist.
* fix(core): hold only a changed endpoint type to the partition, and name malformed region facts
UpdateDomainName checked the partition for EDGE on every patch, so an EDGE custom domain stored in GovCloud before the rule could no longer take a certificate or security-policy update; only a patch that changes the endpoint type is held to the partition now. The source-free region-facts check reports a partition or region entry that is not an object by name instead of failing with a traceback, and its test asserts on computed results rather than on calls that write the fixture.
* fix(core): keep gateway endpoint names on com.amazonaws, allow EDGE only in the commercial partition, and keep SAML working where no sign-on URL is published
The AWS-managed prefix lists belong to the S3 and DynamoDB gateway endpoints, which the CDK names com.amazonaws.<region>.<service> in every partition (GatewayVpcEndpointAwsService); the reversed-suffix table applies to interface endpoints only. The managed lists are back to that name and the cn.com.amazonaws. reservation is gone; DescribeVpcEndpointServices now names the interface services through the table instead, keeping the S3 gateway entry on com.amazonaws.
Edge-optimized API Gateway exists only in the commercial partition: China has CloudFront but no edge-optimized APIs or domains (its API Gateway documentation says so), so EDGE custom domains are refused everywhere else. Where the CDK publishes no SAML sign-on URL (aws-iso-e, aws-iso-f, aws-eusc) assertions keep being checked against the commercial URL, as every partition was before, instead of all being refused. applyEndpointType has its javadoc back.
* refactor(glue): move PartitionProjection from athena to glue package
PartitionProjection resolves Glue table partition layout, not Athena-specific
logic — Athena is only its current caller. Moving it into services/glue gives
the upcoming GlueTableResolver (Redshift Spectrum Phase 2) a home for it
without a glue-depends-on-athena layering inversion.
readPath and assertInjectedColumnsFiltered become public (their callers stay
in services/athena, a different package now); enabled/parameter stay
package-private since nothing outside the class uses them.
* refactor(glue): extract GlueTableResolver from GlueViewDdlBuilder
GlueViewDdlBuilder now delegates table-to-read-plan resolution (read function
inference, read expression, Iceberg detection, column projection) to a new
public GlueTableResolver, so Redshift Spectrum's Glue-backed external tables
can reuse the same logic Athena already proved correct.
* refactor(redshift): extract RedshiftRoleAccess from S3CopySimulator
COPY and UNLOAD's IAM role resolution and S3 authorization now live in a
standalone RedshiftRoleAccess, matching the existing ManifestReader
extraction pattern in this package, so Redshift Spectrum's Glue-backed
external schemas (IAM_ROLE-authorized reads) can reuse it instead of
duplicating role-session and policy-evaluation logic. Adds direct coverage
for the enforced-policy-denial path, which only had implicit
enforcement-off coverage before this extraction.
* fix(redshift): follow RedshiftRoleAccess in native init list and partition baseline
* fix(s3): apply AWS's CreateBucket region rules in every partition
CreateBucket follows the rules moto verified against AWS: the us-east-1 endpoint takes any LocationConstraint but its own (InvalidLocationConstraint), and every other regional endpoint requires a constraint naming exactly its region, answering IllegalLocationConstraintException otherwise. The signing region alone no longer places a bucket, so a China or GovCloud client must send the constraint, which the AWS SDKs do. GetBucketLocation still answers an empty constraint only for us-east-1, in every partition.
WAF's CLOUDFRONT scope lives in the partition's implicit global region and is refused with WAFInvalidParameterException where the partition has no CloudFront. Lightsail lists no regions outside the commercial partition. Region fallbacks read the configured default where a resolver or config is in scope, and PreSignedUrlGenerator gains an overload that signs for a given region. The region-literal category of the partition guardrail is now gated; every remaining literal carries a stated reason.
Tests that created buckets under a regional signing scope with no constraint now send one, and S3IntegrationTest's case that pinned the old signing-region placement is replaced by the rejection and its positive twin.
Part of #4272
* fix(s3,wafv2): answer a us-east-1 constraint off its endpoint as a mismatch, and gate the CLOUDFRONT scope on every operation
A CreateBucket on a regional endpoint other than us-east-1 with LocationConstraint us-east-1 is just another mismatched region, IllegalLocationConstraintException, as moto's aws_verified test_create_bucket_with_wrong_location_constraint records; InvalidLocationConstraint belongs to the us-east-1 endpoint alone (test_bucket_create_force_us_east_1). The body parse no longer rejects us-east-1 early, and bucketRegionForCreate checks the endpoint mismatch first.
WAF's CLOUDFRONT scope was refused in partitions without CloudFront only when creating a resource; validateScope, which every operation already calls, now applies the same check, so a List or Get for that scope answers the same WAFInvalidParameterException.
* fix(wafv2): check the CLOUDFRONT scope against the region each call is about
The previous change checked the scope in validateScope against the request region, but CloudFormation calls the service outside any request, where that region falls back to the deployment default: under a GovCloud default a commercial stack's CLOUDFRONT WebACL was refused on create, update and delete. WafV2Handler now checks Scope=CLOUDFRONT against the region the API request was sent to, before dispatch, so every operation still answers the same error; validateScope checks the enum only, and a create keeps its check against the region it is given where the ARN is built.
* fix(core): build and recognise AWS hostnames in every partition
AwsEndpoints builds the AWS-shaped hosts Floci returns from the region's partition DNS suffix: execute-api, the S3 bucket, regional, dual-stack and website hosts, Cognito and EKS OIDC issuers, APS, Bedrock AgentCore, AppSync and EC2 public DNS names. partitions.json records the regions whose S3 endpoint publishes a dual-stack variant, so DualStackDomainName is only returned there. The S3 virtual-host fallback, the execute-api host filter, the ECR image URI and the CloudFront S3-origin parsers recognise every published suffix, longest first. The CloudFront domain suffix Cognito and API Gateway mint comes from floci.services.cloudfront.domain-suffix.
Two commercial bugs go with it: WebsiteURL uses the dash form (s3-website-<region>) in the nine regions that keep it and ends with a slash, and EMR's public DNS name is compute-1 only in us-east-1.
Also carries the follow-ups from the #4444 review: accessDeniedResponse gets its Javadoc back in IamEnforcementFilter, IamAuthValidator's imports are in order, and the IAM test helper's pair loop cannot read past the array.
Part of #4272
* fix(core): keep CloudTrail S3 hosts and CFN dual-stack attributes consistent with their region
CloudTrail built an S3 data event's Host, TLS host header and resource ARNs from the request scope, but the log writer emits its own deliveries from the flush thread, where the request region falls back to the deployment default: a cn-north-1 trail's self-delivery record said awsRegion cn-north-1 with a .amazonaws.com host and an arn:aws: ARN. buildS3Record now takes the event region emitS3DataEvent already resolves and derives all of them from it.
AWS::S3::Bucket drops a prior DualStackDomainName when an update lands in a region without an S3 dual-stack endpoint, since provision receives the previous attributes on update.
* test(resourceexplorer2): check a regionless ARN's partition against the resource's region
The cn-north-1 CloudTrail self-delivery test left its bucket behind in the shared emulator, and ResourceExplorer2's partition assertion then failed on arn:aws-cn:s3:::loop-logs-..., a correct ARN: S3 ARNs carry no region, so the expected partition fell back to aws. The assertion now takes a regionless ARN's partition from the Region the listing reports, and skips it when that is not a published region (global resources). The CloudTrail test deletes its trail, objects and bucket after each case through PartitionCleanup.
* fix(core): mint every ARN in the request's partition
The build side of the multi-partition plan. 123 of the 126 gated arn:aws: literals in src/main now go through AwsArnUtils.Arn.of for regional resources, RegionResolver.buildGlobalArn for regionless ones minted under a request, and Arn.global with the region's partition where only a region is in scope, so a resource created in cn-north-1 or us-gov-west-1 carries arn:aws-cn: or arn:aws-us-gov:. CloudFormation's AWS::Partition and AWS::URLSuffix pseudo-parameters follow the stack region instead of a literal aws and amazonaws.com, and the SAM transform emits arn:${AWS::Partition}:... as the real translator does.
Seven literals are escaped with a stated reason: the stub-resource marker, the three Greengrass runtime ids from the Lambda Runtime enum, S3 Control's error text, and the two console client ids. The three still gated (the managed policy catalog, Flink and the RDS proxy validator) belong to later phases.
ResourceExplorer2IntegrationTest holds every listed ARN to its region's partition again; P0 had relaxed it to commercial regions while China-region resources were still minted arn:aws:.
Part of #4272
* fix(s3): evaluate a bucket policy against the bucket's own partition
A bucket policy names its bucket in the partition of the bucket's region. The authorization paths built the resource ARN from the request's partition instead, so with bucket names shared across regions a same-account request signed for cn-north-1 against a us-east-1 bucket was checked against arn:aws-cn:s3:::bucket/key, missed an explicit deny on arn:aws:s3:::bucket/*, and was allowed. The seven S3Service call sites now take the partition from the bucket's region, which also drops their dependency on a RegionResolver that the package-private test constructors leave null.
* fix(iam): match S3 resource ARNs against the bucket's own partition under IAM enforcement
IamEnforcementFilter built every S3 resource ARN through a regionless Arn.of, which always yields arn:aws:. Once AWS::Partition follows the stack region, a bucket created in cn-north-1 gets a policy naming arn:aws-cn:s3:::bucket/*, and under IAM enforcement its statements never matched, so an explicit deny was skipped.
ResourceArnBuilder now mints S3 ARNs in the request region's partition, which is right for a bucket that does not exist yet. ResourcePolicyProvider gains resolveResourceArn, a default no-op, and S3ResourcePolicyProvider re-mints an existing bucket's ARN in the partition of the bucket's region before any identity or resource policy is evaluated. S3Service.bucketPartition is the single rule for both layers and for the CopyObject source and presigned POST ARNs in S3Controller.
S3PartitionBucketPolicyIamEnforcementIntegrationTest runs with IAM enforcement alone, so S3's own policy check cannot deny first: the China-bucket deny fails without this change, and the cross-partition deny on a us-east-1 bucket fails if the re-minting step is skipped.
P2 of the multi-partition initiative (#4272), the parse side. StatesIntegration
replaces the literal arn:aws:states::: integration ids the ASL executor and the
definition validator compared against: the CDK builds them as
arn:${Aws.PARTITION}:states:::, so a China or GovCloud state machine never
matched (aws-cdk task-utils.ts:36). Only AWS's three suffixes (.sync, .sync:2,
.waitForTaskToken) parse, and a dispatch that does not read the suffix accepts
none, so sqs:sendMessage.bogus stays unsupported as it was. AwsArnUtils
.resourceIfArnFor replaces the 16 startsWith("arn:aws") probes, so bucket
policies, S3 resource paths, assumed-role principals, SAML role pairs, EKS
instance profiles, Security Hub, OAM and CloudTrail selectors recognise China,
GovCloud and ISO ARNs, and an assumed role's underlying role is rebuilt in the
session's own partition. Where a check used to pin arn:aws: and thereby the
commercial partition, it now pins the partition explicitly: a root principal
matches only a caller of the same partition and account, and a Security Hub
resource ARN must carry the request's partition. The 25 hand-rolled partition
alternations in regexes collapse onto AwsArnUtils.PARTITION_REGEX. The
partition-literal baseline drops from 270 to 195 gated occurrences.
Part of #4272
#4314 removed the partition literals in IamService, CostAnomalyService and
EcrService and dropped their rows from tools/partition/baseline.tsv. #4317
was branched before that and its baseline carried the old rows, so the merge
put them back and make partition-check now fails on main with four
"dropped from 1 to 0" entries. Regenerated with make partition-baseline; no
source change.
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
P0 of the multi-partition plan. tools/partition/partition_literals.py inventories
the arn:aws: prefixes, amazonaws.com hosts, hosted-zone ids and hand-rolled
partition regexes in src/main/java per file against tools/partition/baseline.tsv.
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 only shrinks. Escapes
are a `// partition-literal: <reason>` comment or an allowlist.yaml entry.
Makefile targets (partition-check, partition-baseline, partition-audit,
partition-test), a python-only workflow, AGENTS.md and CONTRIBUTING.md
paragraphs, and the ResourceExplorer2 assertion now checks the partition against
the ARN's region instead of a literal arn:aws:.