Repository navigation
Description
authzPrincipalContext (emulator/authz.go) publishes two keys that name the caller:
aws:PrincipalArn (#714) and, as of #745, aws:username. Two more of the global keys
substrate's own bundled AWS managed policies condition on still have no producer, so a policy
naming either is evaluated against a context that does not hold it:
aws:userid— the unique ID of the caller. AWS publishes<account-id>for the account
root, the user's ownAIDA…for an IAM user, and<role-id>:<role-session-name>for an
assumed role.aws:PrincipalTag/<key>— the tags on the calling entity.
docs/services.md lists both under the keys with no producer, and #745 left a note there
saying what it would take: "the derivation that made [aws:username] honest was to record
the name at the credential lookup, not to parse it back out of an ARN. The same shape of
prerequisite is what the other two still need." This issue is that work.
Why each needs a prerequisite rather than a derivation
aws:userid needs an ID substrate does not mint. CreateUser and CreateRole store no
AIDA…/AROA…, and AssumeRole records no role ID, so there is nothing to publish. Deriving
one from the name would make it stable per-name rather than per-entity, which is the opposite of
what a unique ID is for, and a policy comparing aws:userid against a real AIDA… from a
recorded AWS run would never match either way. The honest fix is to mint the ID at create time —
AWS documents the prefixes and the 21-character shape — store it on the entity, and carry it on
Principal the way UserName now is. The assumed-role form then composes from the stored role
ID and the session name AssumeRole already records.
aws:PrincipalTag/ needs the tags read at resolution time. IAM user and role tags are
modelled (TagUser, TagRole), so unlike aws:userid the data exists — what is missing is that
resolvePrincipal does not read them and Principal has nowhere to put them. It is a lookup on a
path that currently costs one Get, so the cost of the extra read is worth stating in the issue's
own terms rather than assumed away.
Both are more valuable now than before #745, because a produced key is also a variable: with
aws:PrincipalTag/team published, ${aws:PrincipalTag/team, 'company-wide'} — AWS's own
documented example — starts resolving.
Acceptance criteria
-
CreateUser/CreateRolemint and store a unique ID of AWS's documented shape, and
GetUser/GetRolereport it (they report an emptyUserId/RoleIdtoday) -
Principalcarries the ID and the principal's tags, both recorded rather than derived -
aws:useridis published for an IAM user, the account root and an assumed role in AWS's
three documented forms, and absent where AWS publishes nothing -
aws:PrincipalTag/<key>is published for a tagged user or role, and a${aws:PrincipalTag/…}
variable resolves through it - Both keys are produced at both IAM authorization doors, per iam: the condition operator families substrate does not implement are discarded, not refused — ...IfExists, ArnNotLike, numeric, date, IpAddress #714 and iam: policy variables are compared literally, so a negated ${aws:username} is more permissive than on AWS #745 — a key at one
door and not the other is the one-ARN-two-answers class of Principal-aware test mode: enforce IAM authorization in composition tests #411 -
docs/services.md's producerless-key census loses both, and itsaws:usernamenote stops
pointing forward at this
Activity
scttfrdmn commentedon Sep 11, 2026
Scheduled for v0.111.0. Two corrections before the work starts, because the first acceptance
criterion is already met on
main(2decd7f).CreateUser/CreateRoledo mint and store a unique ID, andGetUser/GetRoledo report it.emulator/iam_plugin.go:257—UserID: generateIAMID("AIDA")emulator/iam_plugin.go:480—RoleID: generateIAMID("AROA")generateIAMID(emulator/iam_types.go:301-311) produces AWS's 21-character prefix+random shapeemulator/iam_xml.go:79and:121render<UserId>/<RoleId>from the stored record, whichloadUser/loadRole(iam_plugin.go:2525-2552) read back with no field synthesis or zeroingSubstrate mints one for every entity kind, not just these two:
AGPAgroup (:756),ANPApolicy (
:1259),AKIAaccess key (:1393),AIPAinstance profile (:2746),ASIASTSsession (
sts_plugin.go:197,:363), andAROAfor a service-linked role(
iam_slr_handlers.go:132).So the prerequisite this issue describes is not minting — it is carrying the ID to the
decision, which is genuinely missing:
resolvePrincipal(emulator/credentials.go:162-210) buildsPrincipal{ARN, Type, UserName}from
IAMAccessKey, and that record stores noUserID.AssumeRolecomputesrole.RoleID + ":" + sessionNameatsts_plugin.go:213for the responseand throws it away;
STSSessionCredentials(sts_plugin.go:423-429) stores neither the role IDnor the session name.
The fix keeps this issue's own rule — record at the credential, don't derive — by adding the ID to
IAMAccessKeyatCreateAccessKeyand toSTSSessionCredentialsatAssumeRole/GetSessionToken,so
resolvePrincipalstill needs oneGetfor the ID.Tags cannot be recorded the same way, because they change after the key is created. They live
inline on the entity record (
IAMUser.Tags/IAMRole.Tags,iam_types.go:19-42, merged andrewritten by
tagUser/tagRoleatiam_plugin.go:2197-2219and:2345-2401), soresolvePrincipalhas to read the entity — one extraGeton the path that costs one today. Thatcost will be stated in its doc comment rather than assumed away, as this issue asks.
One narrowing to record now:
AssumeRolereads noTagsparameter at all (there is nooccurrence of
Tagsanywhere inemulator/sts_plugin.go), so session tags are not modelled and anassumed role's
aws:PrincipalTag/<key>will be the role's tags alone. AWS publishes both. Thatwill be documented as a deliberate gap rather than left to look like completeness.
The first acceptance-criteria checkbox will be ticked as already-satisfied with these citations
rather than by changing code that is already correct.
fix(iam): publish the caller's unique ID and tags as condition keys (#…
fix(sts): GetCallerIdentity reports the caller's unique ID, not their…