Skip to content

docs(iam): the simulator's scope, and an e2e journey through it - #648

Merged
scttfrdmn merged 4 commits into
mainfrom
docs/iam-v0.100.0
Aug 15, 2026
Merged

scttfrdmn merged 4 commits into
mainfrom
docs/iam-v0.100.0

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

The documentation and end-to-end half of the v0.100.0 IAM work. No behaviour changes — every operation described here already merged.

docs/services.md was describing the pre-release state

Three entries were actively wrong after this milestone's PRs:

The operation table also omitted seventeen routed operations: the eleven group operations, both Simulate*, both version operations, and DeleteInstanceProfile/RemoveRoleFromInstanceProfile/ListInstanceProfiles. All are now listed with the behaviour worth knowing before calling them.

New prose

"What the policy simulator evaluates" — the three decisions and why the distinction matters to an assertion, exactly what is in the evaluated policy set for each of the two operations, MatchedStatements/MissingContextValues, and the parameter defaults (including that there is no cap on actions per call).

"What the simulator does not evaluate" — a table, one row per omission with its reason, because a fabricated field in a preflight answer is worse than a missing one: SCPs (stored by Organizations, never consulted by CheckAccess either, so OrganizationsDecisionDetail is absent rather than present-and-false), StartPosition/EndPosition (offsets into text substrate does not keep), the cross-account details, and the two ignored mode parameters. It closes by saying plainly that a consumer whose preflight depends on an SCP boundary cannot get that answer here.

"Finding a policy: ListPolicies scope" — that Scope=AWS means the 52-policy catalog, that PathPrefix must begin and end with a slash as IAM requires, that OnlyAttached is computed from stored attachments rather than the catalog's always-zero count, and that PolicyUsageFilter is validated and narrows nothing (with the reason: guessing which side an unused policy falls on would silently drop all 52).

"Attaching a policy substrate does not bundle", rewritten for #499's shipped behaviour, including the consequence a reader actually needs: an attached-but-unresolvable policy contributes no statements, so CheckAccess and the simulator both behave as though it were not attached.

"Policy documents and versions" — the RFC 3986 encoding, and why one version per policy means v1 does not exist for a policy whose default is v2.

test/e2e/journey_iam_simulate_test.go

The point of the milestone, through the real SDK. Four tests:

  • All three decisions in one response. A group's managed allow (AmazonS3ReadOnlyAccess), a user's inline explicit deny, and an action nothing grants — one SimulatePrincipalPolicy call, three actions, three different EvalDecision values, each traced through MatchedStatements to the policy that produced it. Checked together rather than separately, so a handler returning a uniform answer fails. Then RemoveUserFromGroup and the allow becomes an implicit deny, proving the grant was only ever on the group.
  • An unknown principal → asserted through the SDK's typed *NoSuchEntityException, which is what proves the wire shape rather than just the status code.
  • SimulateCustomPolicy over documents that were never stored — the form a tool uses to check a policy it is about to write — including ResourceArns defaulting to *, and a boundary flipping an allow to an implicit deny with AllowedByPermissionsBoundary=false.
  • MissingContextValues on a conditional grant, and the same simulation allowing once the ContextEntry is supplied. Without this a conditional grant is indistinguishable from a missing one, and a preflight would report "you cannot" where the truth is "not with what you told me".

This level is the one that matters for these operations: a unit test calls the handler directly and never learns whether it is routed (#636), and hand-marshals a body with real arrays while every parameter these two take is a query-protocol .member.N list (#639). Both failure modes are invisible below this line.

Verification

gofmt -l . clean; go build ./...; go vet ./...; golangci-lint run ./... → 0 issues.; make test (race) green; make docs-reference-check docs-versions clean; npm --prefix docs run build clean; go vet -C test/e2e ./... and the full go test -C test/e2e ./... green.

docs/services.md carried the pre-release state: AttachUserPolicy and
AttachRolePolicy "do not verify the policy ARN resolves", ListPolicies
"lists CreatePolicy policies only", and GetPolicyVersion listed as not
implemented. All three shipped in this milestone. The operation table now
covers the eleven group operations, the two Simulate operations and the two
version operations, and three new subsections state what the simulator does
not evaluate and why each absence is honest rather than a gap: SCPs (a bound
CheckAccess does not enforce either, so OrganizationsDecisionDetail is
absent rather than false), statement positions (offsets into text substrate
does not keep), and the cross-account details.

test/e2e/journey_iam_simulate_test.go drives the milestone's point through
the real SDK: one call, three actions, three different decisions, each
traced to the policy that produced it — a group's managed allow, a user's
inline explicit deny, and an ungranted action. Plus the boundary flipping an
allow to an implicit deny, MissingContextValues on a conditional grant, and
NoSuchEntity for an unknown principal asserted through the SDK's typed
error. This level is the one that catches an unroutable operation (#636) and
a .member.N list that never reaches a handler (#639); both are invisible to
a unit test that calls the handler with a hand-built body.
@codecov

codecov Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The live CLI gate showed --path-prefix /service-role/ returning three, not
the five service-role policies the prose claimed. AmazonSSMManagedInstanceCore
and AmazonEC2ContainerRegistryReadOnly are service-role policies that AWS
publishes at /, and the Path substrate reports is AWS's — what a policy is
for and where it lives are different things.
…unds

Two mutation-testing survivors, both in the #499 code.

iamWarnUnresolvedPolicyARN returned whether the ARN resolved and no caller
used it, so a mutant flipping every one of those returns passed the whole
suite. A bool nothing reads is a value no test can observe; the log line is
the entire observable effect, so the function now returns nothing and says
why. The nil-logger guard moves to the top, where it also skips two state
reads that could not have produced anything.

The ARN length bound survived removal in both directions because the
refusal tests asserted only the InvalidInput code, which the pattern arm
produces too. The malformed-ARN table now asserts the message, and carries a
case for each of arnType's own bounds — under 20 and over 2048 characters.
PluginConfig.Logger is optional, so iamWarnUnresolvedPolicyARN's guard is a
reachable branch: nothing was asserting that an attach with no logger still
records the attachment rather than failing on a diagnostic nobody is
listening for.
@scttfrdmn
scttfrdmn merged commit ca752b9 into main Aug 15, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the docs/iam-v0.100.0 branch August 15, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant