Skip to content

fix(iam): an entity read reports its tags (#796) - #811

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/796-entity-tags
Sep 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/796-entity-tags

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

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/ListPolicyTags and the
three instance-profile equivalents) follow in the next PR, which is the one that closes the issue.

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, 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 Tags member when the entity has tags: CreateUser, GetUser,
CreateRole, GetRole, CreateServiceLinkedRole, CreatePolicy, GetPolicy,
CreateInstanceProfile, GetInstanceProfile.

The list shapes deliberately report none. ListUsers, ListRoles, ListPolicies and
ListInstanceProfiles each carry the same note verbatim:

IAM resource-listing operations return a subset of the available attributes for the resource.
This operation does not return the following attributes, even though they are an attribute of
the returned object: PermissionsBoundary, RoleLastUsed, Tags. To view all of the information for
a role, see GetRole.

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/iamRoleXMLFields by shape behind a small unexported shape selector. A grep of
every call site shows each single-entity response already goes through exactly one of four
wrappers — iamSingleUserXML, iamSingleRoleXML, iamSinglePolicyXML,
iamSingleInstanceProfileXML — while the listing builders and iamRoleMembersXML call the
…XMLFields helpers directly. So guarding at the four wrappers is equivalent to the selector and
strictly 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. Tags is Required: No on all four data types and every untagged sample
response leaves the element out; CreateInstanceProfile's sample settles the contrast by
rendering its required empty list as <Roles/> while carrying no <Tags> at all. iamTagListXML
is unchanged and still writes the wrapper unconditionally, which is right for ListUserTags/
ListRoleTags, where Tags is 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

CreatePolicy and CreateInstanceProfile accept Tags.member.N, which AWS documents on both and
which each dropped silently for want of anywhere to put it — IAMPolicy and IAMInstanceProfile
gain a Tags field, additively, and a record written by an earlier version reads back untagged.
Groups gain nothing: no Tags on the Group data type, no TagGroup in the Actions index, no
iam:*Group tagging action in the vendored authorization snapshot, and the User Guide says "You
can 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 because
Tags.member.N is what a real client sends (the same reason #639 exists). Five of the seven fail
on main; the other two pin behaviour that must not change (an untagged entity omits the member,
a group never reports one).

gofmt clean, go build, go vet, golangci-lint run ./... 0 issues, make test and
GOTOOLCHAIN=go1.26.6 make test green, make docs-reference docs-reference-check docs-versions authz-reference-check clean, npm --prefix docs run build clean, 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.md gains What an entity read reports about its tags; CHANGELOG.md
updated under ## [Unreleased].

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

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6ac2175 into main Sep 12, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/796-entity-tags branch September 12, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant