Repository navigation
Description
What's missing
GetPolicy on the service-role policies that EC2/SSM workflows attach returns
NoSuchEntity, even though AttachRolePolicy accepts the same ARN. Against
ghcr.io/scttfrdmn/substrate:0.85.0:
IAM get_policy arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore -> NoSuchEntityThe handler is correct — iam_plugin.go:1055 checks the managed catalog before
falling through to stored policies:
// Check managed policies first.
if mp, ok := GetManagedPolicy(params.PolicyArn); ok {
return iamXMLResponse(http.StatusOK, "GetPolicy", iamSinglePolicyXML(mp))
}The gap is the catalog contents. emulator/iam_managed.go seeds exactly the
47 policies from #13, and they are all user/administrator-oriented
(AdministratorAccess, PowerUserAccess, ReadOnlyAccess, plus per-service
*FullAccess/*ReadOnlyAccess pairs). Not one service-linked / instance-role
policy is present. Missing ones that come up constantly:
| Policy | Attached to | Used for |
|---|---|---|
AmazonSSMManagedInstanceCore |
EC2 instance role | Session Manager, SendCommand — the standard agent policy |
AmazonEC2ContainerRegistryReadOnly |
ECS task execution role | pulling images from ECR |
service-role/AmazonECSTaskExecutionRolePolicy |
ECS task execution role | the documented Fargate execution role |
service-role/AWSLambdaBasicExecutionRole |
Lambda execution role | CloudWatch Logs |
service-role/AWSLambdaVPCAccessExecutionRole |
Lambda execution role | VPC-attached Lambdas |
AmazonSSMFullAccess and AmazonSSMReadOnlyAccess are seeded, so SSM is
represented — but by the human-operator policies, not the one an instance profile
actually gets.
Note the service-role/ path prefix on three of these: the ARN is
arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole, so whatever
lookup GetManagedPolicy does needs to handle a path component, not just a bare
name.
Why it matters
The asymmetry is the awkward part: attach_role_policy accepts the ARN and
succeeds, so a test that only attaches passes, and one that then reads the policy
back fails. That reads as a bug in the consumer rather than a catalog gap.
In parsl-aws-provider,
AmazonSSMManagedInstanceCore is attached to every EC2 instance profile the
provider creates — SSM is the universal connectivity mechanism there, so it's on
the main path, not an edge case. Its unit suite therefore has to keep moto with
MOTO_IAM_LOAD_MANAGED_POLICIES=true to get real policy documents. That's one of
three reasons
parsl-aws-provider#183
("retire moto where substrate now suffices") could only be answered partially.
Suggested fix
Add the service-role policies above to iam_managed.go — the same shape as the
existing mp(...) entries, and mechanical once path-prefixed ARNs resolve. Real
document bodies would be ideal (moto vendors them, so there's precedent for it
being tractable), but even correct metadata with a representative document would
clear the asymmetry.
If a full catalog isn't wanted, the alternative that still helps: make
AttachRolePolicy reject an ARN that GetPolicy can't resolve, so the two
operations agree. Failing at attach time points straight at the cause instead of
surfacing three calls later.
Reproduce
$ docker run -d -p 4566:4566 ghcr.io/scttfrdmn/substrate:0.85.0
$ export AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_DEFAULT_REGION=us-east-1
$ ARN=arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
$ aws --endpoint-url http://localhost:4566 iam create-role --role-name probe \
--assume-role-policy-document '{"Version":"2012-10-17","Statement":[]}' >/dev/null
$ aws --endpoint-url http://localhost:4566 iam attach-role-policy \
--role-name probe --policy-arn $ARN && echo "attach: OK"
attach: OK
$ aws --endpoint-url http://localhost:4566 iam get-policy --policy-arn $ARN
An error occurred (NoSuchEntity) ... Policy arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore was not found.
Activity
feat(iam): bundle the five service-role managed policies (#484) (#500)
scttfrdmn commentedon Aug 2, 2026
Fixed in
262b911(#500), shipping in v0.87.0 — by seeding the catalog, not by rejecting the attach. You offered both and the choice deserves an argument rather than a silent pick.Why not reject the ARN. Real IAM does validate that the policy exists, so on pure fidelity your alternative is the more correct one. But substrate bundles 52 managed policies out of roughly 1,200. Making
AttachRolePolicyrefuse an unresolvable ARN would refuse every attach of the other ~1,150 — trading a confusing success for a wrong failure, and breaking consumers whose IaC is entirely valid. Seeding the catalog fixes your reported case without that cost. The general asymmetry is real and is now filed as #499, with this reasoning recorded there so the decision is written down instead of implied.The actual work was the path, not the policy documents.
mp()hardcodedARN: "arn:aws:iam::aws:policy/" + nameandPath: "/", so aservice-role/policy was inexpressible — three of the five you asked for live there. There is now a siblingmpAt(path, name, …)that sets both the path and the path-bearing ARN, withmpexpressed in terms of it so there is one construction rather than two that can drift.GetManagedPolicyneeded no change: it is an exact-ARN map lookup, and the ARN is now right.PolicyNamestays the bare name (AWSLambdaBasicExecutionRole) with the path separate, because that distinction is what a path query reads — getting it wrong makes a policy findable by ARN and invisible to a listing.The five, each with its document copied verbatim from its AWS managed-policy reference page and the URL in a comment beside it:
arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore— your reported case; threeAllowstatements overssm:,ssmmessages:andec2messages:actions on"*"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnlyarn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicyarn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRolearn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRoleThe documents are fetched rather than written from memory deliberately: #411 (principal-aware IAM) will evaluate them for real, so a plausible-looking document would become a wrong authorization decision later.
Your exact sequence is now a test —
CreateRole→AttachRolePolicy(SSM core)→GetPolicy(same ARN)→ 200, notNoSuchEntity— and the bundled count assertion moved 47 → 52 in all three places that state it.One gap found while verifying your report, wider than what you filed:
ListPoliciesparsesScopeandPathPrefixand applies neither, and it lists only stored policies — so all 52 bundled ones are invisible to any listing, including--scope AWS. Yourservice-role/policies are findable by ARN but not enumerable. Filed as #497; it is unrelated to your reproduction, which is why it is separate rather than folded in.Also filed: #498 (
GetPolicyVersionis unimplemented, so a policy document is not observable over the wire even for a policy that resolves).chore(release): v0.87.0 (#515)