Repository navigation
feat(iam): service-linked roles, and a producer for iam:AWSServiceName (#747) - #773
Merged
Merged
Conversation
#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 Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CreateServiceLinkedRole,DeleteServiceLinkedRoleandGetServiceLinkedRoleDeletionStatusansweredInvalidAction/400, which made eleven of the32 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:
iamAuthzRequestContextpublishesiam:AWSServiceNameat the genericgate;
authorizeWithcarries it at the handler. It reads either wire form (the queryprotocol's
Paramsand the JSON protocol'sBody), so a decision does not depend on which acaller chose.
Resourcetoarn: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. Allthree operations now name a real ARN — including the status poll, whose
DeletionTaskIdembeds 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:
TestIAM_BundledPolicyGrantsCreateServiceLinkedRoleasserts both doors reach the same verdictunder 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
InvalidInput/400, notEntityAlreadyExists— the operation publishesfour errors and that is not among them, so it cannot be a copy of
CreateRole's.NoSuchEntity/404 on the delete (noInvalidInputis published there); the message says which.DeleteRolerefuses a service-linked role withUnmodifiableEntityat HTTP 400 — not the409 its
DeleteConflictarms use — without whichDeleteServiceLinkedRolewould bedecorative.
Seedable deletion outcome
POST/DELETE /v1/iam/slr-deletion-status, keyed by role name or"*". The failure AWSdocuments 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
SUCCEEDEDtask removesthe role record — the observable difference the two outcomes turn on.
Provenance
The
AWSServiceRoleFor…name is substrate's convention, not AWS's rule. AWS publishes noderivation and the User Guide warns against inferring even the principal, so the table holds
exactly the six principals a bundled statement names inside a
Resourceand everything else isderived (strip
.amazonaws.com, title-case each segment). It is deliberately not padded withthe other well-known names: a guessed row would be indistinguishable from a cited one. One
bundled statement scopes a
Resourcearound an untabled principal — AWSBatchFullAccess'sarn:aws:iam::*:role/*Batch*— and the derivedAWSServiceRoleForBatchsatisfies it becausethat pattern is a contains-glob.
CustomSuffixjoins 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-lintclean (0 issues);make testandmake coveragepass with emulator 83.4%, total 82.9% (baseline held);
make docs-reference docs-reference-check docs-versionsclean; vitepress build clean with an empty anchor diff;go vet -C test/e2eandgo test -C test/e2epass.Live fail-before/pass-after through the AWS CLI (the query protocol, so
Paramsisexercised): all three operations answered
InvalidActionand the seed endpointServiceNotAvailableonmain; after, the create returns the role with its trust policy,DeleteRoleanswersUnmodifiableEntity, a seededFAILEDreports itsReason/RoleUsageListand leaves the role in place, a cleared seed deletes it and reports
SUCCEEDED, and an unknowntask is
NoSuchEntity.Closes #747