Repository navigation
fix(iam): an entity read reports its tags (#796) - #811
Merged
Merged
Conversation
Tags were stored and never reported: TagRole wrote them, ListRoleTags read them back, and GetRole reported none — so a consumer comparing desired state against the entity read saw permanent drift. AWS draws the line by shape rather than by entity, so the rendering is guarded at the four single-entity wrappers (User, Role, Policy, InstanceProfile) and not added to the field builders each of those shares with a listing: ListUsers, ListRoles, ListPolicies and ListInstanceProfiles all document that they report no Tags, and the roles nested in an instance-profile shape are covered by the same note. An untagged entity omits the member rather than rendering an empty list, per `Required: No` plus every untagged sample response — CreateInstanceProfile's sample renders its required empty list as <Roles/> while carrying no <Tags>. CreatePolicy and CreateInstanceProfile accept Tags.member.N, which AWS documents on both and which each dropped silently for want of a field to store it in. Groups gain nothing: they are not a taggable IAM resource.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of #796, split by what it touches: this PR is what a read reports and what a create
accepts; the six missing tagging operations (
TagPolicy/UntagPolicy/ListPolicyTagsand thethree instance-profile equivalents) follow in the next PR, which is the one that closes the issue.
Tags were stored and never reported.
TagRolewrote them,ListRoleTagsread them back, andGetRolereported none — so a consumer comparing desired state against the entity read sawpermanent drift, and a CDK or Terraform plan proposed the same tag change every time.
AWS draws the line by shape, not by entity
Nine responses now carry a
Tagsmember when the entity has tags:CreateUser,GetUser,CreateRole,GetRole,CreateServiceLinkedRole,CreatePolicy,GetPolicy,CreateInstanceProfile,GetInstanceProfile.The list shapes deliberately report none.
ListUsers,ListRoles,ListPoliciesandListInstanceProfileseach carry the same note verbatim:The roles nested inside an instance-profile shape are a list too, and carry none for the same
reason.
One simplification of the plan, disclosed: the plan proposed splitting
iamUserXMLFields/iamRoleXMLFieldsby shape behind a small unexported shape selector. A grep ofevery call site shows each single-entity response already goes through exactly one of four
wrappers —
iamSingleUserXML,iamSingleRoleXML,iamSinglePolicyXML,iamSingleInstanceProfileXML— while the listing builders andiamRoleMembersXMLcall the…XMLFieldshelpers directly. So guarding at the four wrappers is equivalent to the selector andstrictly simpler: the listings carry no tags by construction, with no new indirection to keep
correct.
An untagged entity omits the member
Not an empty list.
TagsisRequired: Noon all four data types and every untagged sampleresponse leaves the element out;
CreateInstanceProfile's sample settles the contrast byrendering its required empty list as
<Roles/>while carrying no<Tags>at all.iamTagListXMLis unchanged and still writes the wrapper unconditionally, which is right for
ListUserTags/ListRoleTags, whereTagsis required.No existing test could have caught this either way: every assertion reads a decoded map, which
cannot tell an absent element from an empty one. The new ones read the XML.
Create-time tags, and groups
CreatePolicyandCreateInstanceProfileacceptTags.member.N, which AWS documents on both andwhich each dropped silently for want of anywhere to put it —
IAMPolicyandIAMInstanceProfilegain a
Tagsfield, additively, and a record written by an earlier version reads back untagged.Groups gain nothing: no
Tagson theGroupdata type, noTagGroupin the Actions index, noiam:*Grouptagging action in the vendored authorization snapshot, and the User Guide says "Youcan tag most IAM resources, but not groups, assumed roles, access reports, or hardware-based MFA
devices."
Verification
Seven new tests in
emulator/iam_entity_tags_test.go, driving the query protocol becauseTags.member.Nis what a real client sends (the same reason #639 exists). Five of the seven failon
main; the other two pin behaviour that must not change (an untagged entity omits the member,a group never reports one).
gofmtclean,go build,go vet,golangci-lint run ./...0 issues,make testandGOTOOLCHAIN=go1.26.6 make testgreen,make docs-reference docs-reference-check docs-versions authz-reference-checkclean,npm --prefix docs run buildclean,go vet -C test/e2e ./... && go test -C test/e2e ./...green. Patch coverage of the changed production lines: 13/13.Part of #796.
docs/services.mdgains What an entity read reports about its tags;CHANGELOG.mdupdated under
## [Unreleased].