Skip to content

feat(iam): service-linked roles, and a producer for iam:AWSServiceName (#747) - #773

Merged
scttfrdmn merged 1 commit into
mainfrom
iam-service-linked-roles-747
Aug 23, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
iam-service-linked-roles-747

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

CreateServiceLinkedRole, DeleteServiceLinkedRole and
GetServiceLinkedRoleDeletionStatus answered InvalidAction/400, which made eleven of the
32 condition blocks
in the bundled managed-policy catalog unevaluatable — the largest single
group in the producerless-key census, all eleven turning on a parameter of an operation that
did not exist.

Two producers, not one

IAM authorizes through two doors that would otherwise disagree — the one-ARN-two-answers class
of #411 — so this closes both:

  • The condition key. iamAuthzRequestContext publishes iam:AWSServiceName at the generic
    gate; authorizeWith carries it at the handler. It reads either wire form (the query
    protocol's Params and the JSON protocol's Body), so a decision does not depend on which a
    caller chose.
  • The request resource. Four of the eleven statements scope Resource to
    arn:aws:iam::*:role/aws-service-role/…, two of those to an exact ARN with no trailing *,
    none of which the flat arn:aws:iam::<account>:* every IAM request carried can match. All
    three operations now name a real ARN — including the status poll, whose DeletionTaskId
    embeds the service and the role, so its resource resolves with no state read and therefore
    still resolves after the role is gone.

Both halves are load-bearing, verified by disabling each in turn:

# gate arm off:   ... on resource: arn:aws:iam::123456789012:*
# key producer off: ... on resource: arn:aws:iam::123456789012:role/aws-service-role/lambda.amazonaws.com/AWSServiceRoleForLambda

TestIAM_BundledPolicyGrantsCreateServiceLinkedRole asserts both doors reach the same verdict
under AWSLambda_FullAccess, which is the only bundled statement granting the action — so the
allow is genuinely earned by the ARN and the condition.

The key is published for the create and the delete and not for the status operation,
matching where the Service Authorization Reference lists it. Publishing a key AWS does not is
the permissive direction.

Refusals, none of them the obvious one

  • A duplicate name is InvalidInput/400, not EntityAlreadyExists — the operation publishes
    four errors and that is not among them, so it cannot be a copy of CreateRole's.
  • A role that exists but is not service-linked is NoSuchEntity/404 on the delete (no
    InvalidInput is published there); the message says which.
  • DeleteRole refuses a service-linked role with UnmodifiableEntity at HTTP 400 — not the
    409 its DeleteConflict arms use — without which DeleteServiceLinkedRole would be
    decorative.

Seedable deletion outcome

POST/DELETE /v1/iam/slr-deletion-status, keyed by role name or "*". The failure AWS
documents is a linked service still using the role, unreachable in an emulator that runs none.
The seed is read at submission, not at each poll, because only a SUCCEEDED task removes
the role record — the observable difference the two outcomes turn on.

Provenance

The AWSServiceRoleFor… name is substrate's convention, not AWS's rule. AWS publishes no
derivation and the User Guide warns against inferring even the principal, so the table holds
exactly the six principals a bundled statement names inside a Resource and everything else is
derived (strip .amazonaws.com, title-case each segment). It is deliberately not padded with
the other well-known names: a guessed row would be indistinguishable from a cited one. One
bundled statement scopes a Resource around an untabled principal — AWSBatchFullAccess's
arn:aws:iam::*:role/*Batch* — and the derived AWSServiceRoleForBatch satisfies it because
that pattern is a contains-glob. CustomSuffix joins with _, which is observed behaviour.

Out of scope, filed

IAM's general per-operation request resource is #770. This resolves only the
service-linked-role ARN it needs.

Verification

gofmt/go build/go vet/golangci-lint clean (0 issues); make test and make coverage
pass with emulator 83.4%, total 82.9% (baseline held); make docs-reference docs-reference-check docs-versions clean; vitepress build clean with an empty anchor diff;
go vet -C test/e2e and go test -C test/e2e pass.

Live fail-before/pass-after through the AWS CLI (the query protocol, so Params is
exercised): all three operations answered InvalidAction and the seed endpoint
ServiceNotAvailable on main; after, the create returns the role with its trust policy,
DeleteRole answers UnmodifiableEntity, a seeded FAILED reports its Reason/RoleUsageList
and leaves the role in place, a cleared seed deletes it and reports SUCCEEDED, and an unknown
task is NoSuchEntity.

Closes #747

#747)

The three service-linked-role operations answered InvalidAction/400, which
made eleven of the 32 condition blocks in the bundled managed-policy catalog
unevaluatable — the largest single group in the producerless-key census, all
eleven turning on a parameter of an operation that did not exist.

Making those statements evaluate took two producers, not one, because IAM
authorizes through two doors that would otherwise disagree (#411): the key is
published at the generic gate and passed by the handler, and the request
resource had to become the role's own ARN, since four of the eleven statements
scope Resource to arn:aws:iam::*:role/aws-service-role/… — two to an exact ARN
with no trailing * — none of which the flat arn:aws:iam::<account>:* every IAM
request carried can match. This resolves the resource for the service-linked-
role operations only; IAM's general per-operation resource is #770.

The key is published for the create and the delete and not for the status
operation, matching where the Service Authorization Reference lists it.
Publishing a key AWS does not is the permissive direction.

DeleteRole now refuses a service-linked role with UnmodifiableEntity at HTTP
400, without which DeleteServiceLinkedRole would be decorative. The deletion
outcome is seedable through POST/DELETE /v1/iam/slr-deletion-status, read at
submission because only a SUCCEEDED task removes the role record — the
observable difference the two outcomes turn on.

The AWSServiceRoleFor… name is substrate's convention: the table holds exactly
the six principals a bundled statement names inside a Resource, and everything
else is derived and documented as such.

Closes #747
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.49367% with 81 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/iam_slr_handlers.go 76.88% 21 Missing and 22 partials ⚠️
emulator/iam_control.go 59.25% 16 Missing and 6 partials ⚠️
emulator/iam_authz.go 83.56% 6 Missing and 6 partials ⚠️
emulator/iam_service_linked_roles.go 92.15% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit f38a6cb into main Aug 23, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the iam-service-linked-roles-747 branch August 23, 2026 08:36
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.

iam: CreateServiceLinkedRole, so iam:AWSServiceName has a producer

1 participant