Repository navigation
Description
Summary
SSM's three tag operations decode ResourceType and never read it, so every SSM tag call is
answered as though it named a Parameter Store parameter — whatever type it actually named. And the
Resource Groups Tagging API has no ssm arm at all, so a parameter is invisible to GetResources
and untaggable through TagResources (the eighth of #835's eleven rows).
Verified at 6bcf0ee (v0.116.0) against the tree, and against
API_AddTagsToResource,
API_RemoveTagsFromResource
and
API_ListTagsForResource.
1. ResourceType is decoded and never read, at all three operations
addTagsToResource (emulator/ssm_plugin.go:640-680), removeTagsFromResource (:682-721) and
listTagsForResource (:723-748) each declare
ResourceType string `json:"ResourceType"`and then never mention input.ResourceType again. All three go straight to
p.loadParam(goCtx, ctx.AccountID, ctx.Region, name).
AWS publishes ResourceType as Required: Yes with a ten-value enum:
Valid Values:
Document | ManagedInstance | MaintenanceWindow | Parameter | PatchBaseline | OpsItem | OpsMetadata | Automation | Association | CloudConnector
Consequences, in the order they matter:
{"ResourceType": "Document", "ResourceId": "MyRunbook"}tags the parameter named
/MyRunbook. A caller tagging an SSM document silently writes onto an unrelated Parameter Store
record, andListTagsForResourcewith the same pair reads it back — so the round trip confirms
the wrong resource was tagged. This is the resource-type analogue of the account confusion SQS state keys disagree: the tagging API and the authorizer address queue:<name>, the plugin writes queue:<account>/<name> #826
established for SQS and DynamoDB, Step Functions: all three tag operations take the account from the request, not the ARN, so a foreign-account ARN tags the caller's own state machine #910/cloudfront: the three tagging operations take the account from the caller, not the ARN, and match the resource type by substring #918/fix(kms): a key ARN resolves to the caller's own account, and an alias ARN resolves to its own name #922/fix(sns): a topic ARN resolves to the caller's own account, and a subscription ARN resolves to its own UUID #925/fix(secretsmanager): a SecretId ARN resolves to the secret its own ARN names, and the tagging API reaches a secret #928 carried through Step Functions,
CloudFront, KMS, SNS and Secrets Manager, and Step Functions: all three tag operations take the account from the request, not the ARN, so a foreign-account ARN tags the caller's own state machine #910 stated as the anchored-segment rule.- A
ResourceTypeoutside the enum is accepted.{"ResourceType": "Banana"}succeeds. InvalidResourceType/400 is unreachable. AWS publishes it at all three operations; substrate
can never answer it.- An absent
ResourceTypeis accepted, where AWS makes it required.
Substrate models exactly one taggable SSM resource type — the parameter (ssm_plugin.go:87,
ssm_types.go). It models no documents, maintenance windows, patch baselines, OpsItems, OpsMetadata
objects, automations, associations, managed instances or cloud connectors. That is fine; what is not
fine is answering as though a request naming one of them had named a parameter.
2. A full ARN passed as a Parameter ResourceId is silently turned into a name
AWS is explicit about which form each type takes:
For the
DocumentandParametervalues, use the name of the resource. If you're tagging a shared
document, you must use the full ARN of the document.
So for a parameter the identifier is the name, not the ARN — this is the first of #835's rows
where the owning service's own tag operations do not take an ARN at all. Substrate's normalization
(ssm_plugin.go:650-652) prepends / to anything without one, so
arn:aws:ssm:us-east-1:123456789012:parameter/db/password becomes the name
/arn:aws:ssm:us-east-1:123456789012:parameter/db/password and is looked up as one. It is refused,
but for the wrong reason and after a normalization that makes the message nonsense. Secrets Manager's
resolver settled this shape in #928: anything beginning arn: is a caller who meant an ARN, and
guessing is how a typo becomes a 200 against the wrong resource.
3. addTagsToResource builds its merged tag list by ranging a Go map
ssm_plugin.go:663-674 merges through map[string]string and then
for k, v := range tagMap {
newTags = append(newTags, SSMTag{Key: k, Value: v})
}with no sort. Two identical AddTagsToResource calls in one run can store — and
ListTagsForResource can therefore report — a different order. This is exactly the defect #862
fixed in all four tagging-API merge helpers, still live in SSM's own path. sortTagsByKey
(tagging_plugin.go:1980) is the helper. putParameter (:194) stores input.Tags unsorted too,
so a parameter tagged at creation and one tagged afterwards report their tags in different orders.
4. ListTagsForResource answers "TagList": null for an untagged parameter
SSMParameter.Tags is json:"Tags,omitempty", so it is nil on an untagged parameter, and
ssm_plugin.go:744-746 renders it directly. AWS's TagList is an array; null is not one, and a
strict client decoding a list member from null is entitled to fail.
5. The Resource Groups Tagging API has no ssm arm (part of #835)
Three pieces are missing, the same three every row of #835 needs:
- No
case "ssm":inTaggingPlugin.resolveARN(tagging_plugin.go:1160-1451), so an ARN falls
to thedefaultarm andTagResourcesreports it unsupported. - No
case ssmNamespace:inmergeResourceTags(:1481), so nothing could write the record even
if the ARN resolved. - No scanner, so
GetResourcesnever reports a parameter. The descriptor list (:241-264) holds
twenty-four; a parameter would be the twenty-fifth.
The colon-terminated taggability guard applies again, and this is the sixth namespace to need it:
ssm_plugin.go:87 writes "parameter:" + … and :91 writes "parameter_paths:" + …, whose value is
a JSON array of names. A bare "parameter" prefix matches both. (cert/cert_arns,
cfdist/cfdist_ids, key/key_ids, topic/topic_names and secret/secret_names were the
first five — five of six namespaces reached so far have collided, so it is the default rather than a
per-service discovery.)
ssmParameterARN (ssm_types.go:55-57) is arn:aws:ssm:{region}:{account}:parameter{name} with the
name's own leading / absorbed and no separator in the format string — so the inverse derivation
is exact, and the type segment is parameter matched as a whole /-delimited segment per #910. Its
confusable siblings in the same namespace are document/, servicesetting/, opsmetadata/,
automation-execution/, maintenancewindow/, patchbaseline/ and managed-instance/.
6. InvalidResourceId is answered at 404 where AWS publishes 400
All three sites answer HTTPStatus: http.StatusNotFound (:660, :702, :741). AWS publishes
400 for InvalidResourceId, as it does for InvalidResourceType, TooManyTagsError and
TooManyUpdates; only InternalServerError is 500, and SSM publishes no distinct not-found code
for these operations at all. This is the same class as #921 (ACM), #923 (KMS) and #930 (Secrets
Manager) and will be filed separately on the same reasoning: correcting which resource an
identifier names is a different change from correcting what status a refusal carries. This issue
routes all three sites through one helper so that fix is one line.
Acceptance criteria
- A context-free
ssm_tags.goholding the parameter-ARN parser, the state-key builders, the
taggability guard and the refusal helpers — taking no*RequestContext, so no arm can reach
for the caller's account, per SQS state keys disagree: the tagging API and the authorizer address queue:<name>, the plugin writes queue:<account>/<name> #826. -
ResourceTypeis required at all three operations. A value outside the enum answers
InvalidResourceType/400 (which is what AWS's own description of that code states); a valid
enum value substrate models no resource for answersInvalidResourceId/400, because the type is
one AWS publishes and it is the ID that names nothing. Where AWS is silent, recorded as
substrate's reading. - A
ResourceIdbeginningarn:is refused rather than normalized into a name. - The leading-slash tolerance is kept and documented: substrate's own
putParameternormalizes
Nameto a leading/(ssm_plugin.go:164-166), so a caller who createdMyParammust be
able to tagMyParam. AWS documents this tolerance explicitly only forOpsMetadata, so for
Parameterit is stated as substrate's reading, required by substrate's own normalization. -
addTagsToResourceandputParametersort throughsortTagsByKey, so the order is
deterministic and creation-time and post-hoc tagging agree. -
ListTagsForResourcereports[]rather thannullfor an untagged parameter, and its order
is deterministic. -
TaggingPlugin.resolveARNgains anssmarm through the same parser, so the two APIs cannot
disagree about which parameter an ARN names (cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765's cross-readability criterion). -
mergeResourceTagsgains anssmNamespacearm behind the colon-terminated guard, merging
throughmergeRecordTagListTagson the raw record so no sibling member is truncated. - A scanner reports every parameter in the caller's account and Region, and the descriptor list
reaches twenty-five. - Tests are behavioural, through
emulator.StartTestServerand signed wire calls only — no
helper writing state directly, per cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765. Including: aDocument/OpsItem/MaintenanceWindow
ResourceTypedoes not reach a same-named parameter; an out-of-enum type is refused; an ARN as
ResourceIdis refused; a tag written through SSM is reported byGetResourcesand vice
versa; a parameter in another Region or account is not reported or tagged; a hierarchical name
round-trips through its ARN; the order is deterministic across two identical calls. -
docs/services.mdandCHANGELOG.mdupdated.
Activity
fix(ssm): a tag call resolves to the resource type it names (#932) (#934
fix(tagging): scope every scanned resource to the caller's account an…