You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
reaper: delete unattached spored managed policies (/spore-host/spored-*-vN) it detaches #1576
#1573 moves the spored grants into customer-managed policies at arn:aws:iam::<account>:policy/spore-host/spored-{policy,baseline-policy,nested-baseline-policy}-v<schema>, one per document per schema per account, attached to the spored roles.
Who deletes them after that PR:
pkg/aws.deleteRole (spawn cleanup, spawn pool drain) deletes a spored policy it detaches when no other role has it attached (IAM's DeleteConflict is the check).
spawn cleanup --instance-roles runs instancerole.SweepSporedPolicies: spored-named policies at /spore-host/, AttachmentCount == 0, created more than 24 h ago.
A launch at a newer schema detaches the older version from its role and deletes it if that was the last attachment.
The gap: the TTL reaper's role sweep (pkg/instancerole.Delete, called from lambda/ttl-reaper/instanceroles.go) detaches every managed policy from a role it deletes, spored ones included, but never deletes the policy. Its iamAPI has no DeletePolicy/ListPolicies, and pkg/reaperiam grants nothing on policy/*. So when the reaper deletes the last spawn-instance-* role carrying an older schema's baseline policy, that policy stays until someone runs spawn cleanup --instance-roles.
Size of it: at most three policies per schema per account (customer-managed policies are free, and the account quota is 1,500). This is clutter, not cost, which is why #1573 left it out of the patch release rather than taking on a reaper redeploy.
To fix:
Call instancerole.SweepSporedPolicies from the reaper's instance-role sweep, under REAPER_INSTANCE_ROLES, so report mode only reports.
Add iam:ListPolicies (Resource *; IAM has no narrower one) and iam:DeletePolicy on arn:aws:iam::*:policy/spore-host/* to the three reaper policies in pkg/reaperiam. The drift gate will require them once the iamAPI declares the methods.
Activity