Repository navigation
Description
GetPolicyVersion is not implemented, so a policy document is not observable over the wire
at all. GetPolicy returns metadata only — iamPolicyXMLFields (iam_xml.go:207-233)
emits PolicyId, PolicyName, Arn, Path, DefaultVersionId, AttachmentCount,
CreateDate and UpdateDate, and deliberately not the document, which matches AWS.
ListPolicyVersions is likewise absent.
Found while implementing #484 (v0.87.0), which seeded five service-role managed policies
with documents copied verbatim from their AWS reference pages. Those documents are real and
correct, and a Go consumer reads them through GetManagedPolicy; a consumer over the wire
cannot read them at all, which is one of the reasons a downstream project keeps moto around.
What AWS does
Per the GetPolicyVersion reference:
- Parameters:
PolicyArnandVersionId, both required.VersionIdmatches
v[1-9][0-9]*(\.[A-Za-z0-9-]*)?. - Returns one
PolicyVersioncontainingDocument,IsDefaultVersion,VersionIdand
CreateDate. - The document is URL-encoded per RFC 3986 — "You can use a URL decoding method to
convert the policy back to plain JSON text." SDKs mostly decode it automatically, so
emitting it un-encoded would work with an SDK and break a raw HTTP client, which is the
detail to get right rather than approximate. - Errors:
InvalidInput400,NoSuchEntity404,ServiceFailure500.
Scope note
Substrate models exactly one version per policy: IAMPolicy has a single Document and a
DefaultVersionID, and CreatePolicyVersion/SetDefaultPolicyVersion/DeletePolicyVersion
do not exist. So GetPolicyVersion can serve the default version faithfully and must decide
what to do with a request for any other version. Returning NoSuchEntity for a
non-default VersionId is honest; pretending v1 exists when the policy reports v3 as its
default is not. The bundled catalog reports the real AWS default versions (v2 for
AmazonSSMManagedInstanceCore, v3 for AWSLambdaVPCAccessExecutionRole), so this is
reachable immediately rather than hypothetical.
Acceptance criteria
-
GetPolicyVersionreturns the document for a bundled managed policy and for a
CreatePolicyone. - The document is URL-encoded per RFC 3986, and a test decodes it back to the JSON the
catalog holds rather than asserting the encoded bytes. -
IsDefaultVersionistruewhenVersionIdequals the policy'sDefaultVersionID. - A
VersionIdother than the default →NoSuchEntity404, with the multiple-version
gap named indocs/services.md. - A malformed
VersionId(not matching the pattern) →InvalidInput400. - An unknown
PolicyArn→NoSuchEntity404. - Decide whether
ListPolicyVersionsships alongside — a consumer that calls one
usually calls the other — or is filed separately. -
docs/services.mdIAM operations table updated.
Activity
feat(iam): bundle the five service-role managed policies (#484) (#500)
feat(iam): a managed policy's document is readable over the wire (#498)…