Skip to content

IAM: GetPolicyVersion is unimplemented, so no policy document is observable over the wire #498

Closed

Description

@scttfrdmn

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: PolicyArn and VersionId, both required. VersionId matches
    v[1-9][0-9]*(\.[A-Za-z0-9-]*)?.
  • Returns one PolicyVersion containing Document, IsDefaultVersion, VersionId and
    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: InvalidInput 400, NoSuchEntity 404, ServiceFailure 500.

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

  • GetPolicyVersion returns the document for a bundled managed policy and for a
    CreatePolicy one.
  • 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.
  • IsDefaultVersion is true when VersionId equals the policy's DefaultVersionID.
  • A VersionId other than the default → NoSuchEntity 404, with the multiple-version
    gap named in docs/services.md.
  • A malformed VersionId (not matching the pattern) → InvalidInput 400.
  • An unknown PolicyArn → NoSuchEntity 404.
  • Decide whether ListPolicyVersions ships alongside — a consumer that calls one
    usually calls the other — or is filed separately.
  • docs/services.md IAM operations table updated.

Activity

  1. added
    type: feature
    area: iam
    on Aug 2, 2026
  2. added this to the v0.100.0 milestone on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: iamfidelitytype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions