Skip to content

IAM: model PermissionsBoundaryUsageCount on the policy shapes #815

Closed

Description

@scttfrdmn

What

PermissionsBoundaryUsageCount on AWS's Policy data type is not modelled. v0.113.0's #807 work
renders every other documented member of the IAM policy shapes (Description, IsAttachable) from
state substrate already keeps, and states this one as unmodelled with its cost. This issue is that
cost.

AWS documents it on the Policy type
(https://docs.aws.amazon.com/IAM/latest/APIReference/API_Policy.html):

PermissionsBoundaryUsageCount — The number of entities (users and roles) for which the policy
is used to set the permissions boundary.

API_ListPolicies' sample response renders it, so it belongs on both policy shapes, not only
GetPolicy.

Why it is not a one-liner

Substrate stores a boundary as an ARN on the entity (IAMUser/IAMRole), not as a back-reference on
the policy, so the count is derivable but not stored. Two implementations, both with a real cost:

  1. Scan on read — enumerate every user and role on each GetPolicy/ListPolicies and count
    matching boundary ARNs. Correct by construction and needs no new state, but makes a policy read
    O(entities) and makes ListPolicies O(policies x entities).
  2. Reference counting — a counter on IAMPolicy maintained across the four boundary operations
    (PutUserPermissionsBoundary, DeleteUserPermissionsBoundary, PutRolePermissionsBoundary,
    DeleteRolePermissionsBoundary) and on DeleteUser/DeleteRole, which drop a boundary
    implicitly. Cheap to read, but every path that can detach a boundary has to be found and none can
    be missed — and a count rebuilt from a recorded event log has to agree with one accumulated live,
    or replay diverges.

Option 1 is the more likely answer for an emulator whose entity counts are test-sized, but it is a
performance decision worth making deliberately rather than in passing.

Acceptance criteria

  • PermissionsBoundaryUsageCount is rendered on both GetPolicy and ListPolicies, per AWS's
    Policy type and the ListPolicies sample
  • The count reflects users and roles, and reaches zero when the last boundary is removed
  • Whichever approach is chosen, replay of a recorded run reports the same count as the live run
  • Deleting an entity that has the policy as its boundary decrements the count
  • The iam_xml.go comment fix(iam): entity shapes over- and under-report documented members #807 left pointing at this issue is replaced by the implementation

Activity

  1. added
    type: feature
    area: iam
    on Sep 12, 2026
  2. added this to the v0.114.0 milestone on Sep 12, 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: iamtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions