fix(core): compare ARN partitions with the resource's region, not the literal aws (#4791)

* fix(core): compare ARN partitions with the resource's region, not the literal aws

Part of #4272 (P10b). Running the Java SDK suite against a Floci deployed in
cn-north-1 (#4790) found five checks comparing a parsed ARN with "aws" and a
seeded ARN fixed to the commercial partition:

- RdsService.hasRdsResourceIdentity required partition aws, so DB instances,
  clusters, DB and cluster snapshots and subnet groups created outside aws
  failed their own ownership check and were not found right after creation.
  The proxy target group check had the same comparison, and CopyDBSnapshot
  refused any source ARN outside aws; it now requires the target region's
  partition, since a snapshot copies within its partition.
- ElastiCache ListTagsForResource rejected every arn:aws-cn: ARN; it now
  expects the request region's partition and names it in the message.
- RAM ignored organization principals outside aws; any published partition is
  accepted, the organization id ties the principal to the caller's.
- The seeded IAM Identity Center instance was arn:aws:sso:::instance/... in
  every deployment, so China permission sets never found it. It now takes the
  partition of the deployment's home region, and AddRegion compares against
  the instance's own primary region instead of a fixed us-east-1.

* fix(sso): move a persisted bootstrap instance to its partition, and drop the fixed China allowlist entries

Greptile on #4791: a deployment persisted before the seeded instance took its
partition keeps it as arn:aws:sso:::instance/..., while its permission sets were
already minted in the instance's own partition, so the fix would not reach it.
ensureBootstrapInstance now rewrites a stored bootstrap instance whose ARN is
not in its primary region's partition.

pgermosen on #4791: with #4790 on main, the cn-north-1 allowlist entries this
fixes would turn stale and fail the nightly. Measured against this branch in
cn-north-1: CloudFormationRdsDynamicReferenceTest, the ten RdsControlPlaneTest
entries, RdsJdbcCompatTest#createDbInstanceAndConnectWithPassword and
SsoPortalTest now pass and are deleted. The four IAM-token connection tests
still fail because they sign their tokens for a pinned us-east-1, which a
cn-north-1 database rightly refuses; they move to the group of tests that pin
commercial values.

* fix(ram): answer the listing operations for the request's region only

Greptile on #4791: with organization principals accepted in every partition,
a commercial GetResourceShares from a member of the organization returned a
China share. The cause predates this PR: GetResourceShares, ListResources,
ListPrincipals and GetResourceShareInvitations walked every stored share, so
a share created in eu-west-1 was listed through us-east-1 too, while a
resource share is a regional resource. RamController now passes the request
region and the four operations keep only shares (and invitations to shares)
in it, which also keeps a share out of another partition.

* fix(ram): resolve a share or invitation to mutate in the request's region only

pgermosen on #4791: after the listings were scoped to the request's region,
findOwnedShare still walked every stored share, so a share invisible to
GetResourceShares in one region could still be deleted, updated, associated,
disassociated or retagged from there; AssociateResourceShare would add a
resource the same endpoint's ListResources does not report. Accept and
RejectResourceShareInvitation had the same gap.

The six share mutations and the two invitation responses now take the request
region from RamController and resolve only a share or invitation in it: one
from another region gets UnknownResourceException or
ResourceShareInvitationArnNotFoundException, like an ARN that does not exist.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-01 21:00:35 -04:00
1 parent 9840b5a998
commit d72923ab33
11 files changed
+408 -188

No files matched your search

@@ -57,6 +57,10 @@ OrganizationsTest#testFullLifecycle
PipesTest#batchSizeInSourceParameters
PipesTest#filterCriteriaFiltersMessages
PipesTest#sqsToSqsForwarding
RdsIamTokenCompatTest#sdkGeneratedTokenIsAccepted
RdsJdbcCompatTest#connectWithIamAuthToken
RdsJdbcCompatTest#modifyKeepsProxyReachableAndDeleteReleasesPort
RdsJdbcCompatTest#toggleIamViaModifyOnRunningInstance
ResourceExplorer2Test#viewFiltersFilterStringDeserializes
Route53Test#crossAccountVpcAssociationLifecycleUsesAwsSdkWireContract
S3TablesTest#createsAndGetsTableBucket
@@ -109,29 +113,6 @@ S3Test#getBucketLocationEuCentral1
StsTest#assumeRoleWithSaml
StsTest#assumeRoleWithSamlAssumedRoleUser
# Floci bugs: RdsService checks a parsed ARN against the literal partition "aws", so RDS
# resources created in China are not found after creation; the seeded IAM Identity Center
# instance ARN is always arn:aws:. CloudFormationRdsDynamicReferenceTest and SsoPortalTest were
# reproduced alone (they pass under us-east-1); the other RDS entries fail the same way. Fixed in
# a follow-up PR.
CloudFormationRdsDynamicReferenceTest#resolvesSecureSsmMasterPassword
RdsControlPlaneTest#sdkCopiesModifiesAndDeletesManualSnapshots
RdsControlPlaneTest#sdkCreatesCopiesRestoresAndDeletesClusterSnapshots
RdsControlPlaneTest#sdkFaultsDeletingAnOptionGroupStillAttachedToAnInstance
RdsControlPlaneTest#sdkRegistersDescribesAndDeregistersDbProxyInstanceTarget
RdsControlPlaneTest#sdkResizesAndUpgradesAStandaloneInstance
RdsControlPlaneTest#sdkRoundTripsAuroraServerlessV2ScalingConfiguration
RdsControlPlaneTest#sdkRoundTripsDbProxyAndItsDefaultTargetGroup
RdsControlPlaneTest#sdkRoundTripsIamDefaultAuthAndProxyUpdates
RdsControlPlaneTest#sdkStopsAndStartsAStandaloneInstance
RdsControlPlaneTest#sdkUnmarshalsDbSubnetGroupSubnets
RdsIamTokenCompatTest#sdkGeneratedTokenIsAccepted
RdsJdbcCompatTest#connectWithIamAuthToken
RdsJdbcCompatTest#createDbInstanceAndConnectWithPassword
RdsJdbcCompatTest#modifyKeepsProxyReachableAndDeleteReleasesPort
RdsJdbcCompatTest#toggleIamViaModifyOnRunningInstance
SsoPortalTest#listAccountsUsesAwsSdk
# Passes alone: in the full run OrganizationsTest#testFullLifecycle fails its arn:aws: assertion
# before cleanup, leaving the caller as the Organizations management account.
SsoAdminAccountAssignmentTest#createInstanceQuotaUsesAwsSdk