Repository navigation
feat(tagging): GetResources reports an ECS service, task and task definition (#935), and a ResourceTypeFilters type is the ARN's own segment (#936) - #940
Merged
Conversation
…inition (#935) The ECS namespace had one scanner descriptor, scanECSClusters, so a tag written to a service, a task or a task definition through TagResources -- which has worked since v0.115.0, and reads back through ECS's own ListTagsForResource -- was invisible to GetResources. That is the asymmetry every row of #835 closes, and this is the eleventh and last of them. A task ships with the two rows #835's table names: ecsTagStateKey already resolved a task ARN, and AWS lists tasks first among the taggable ECS resources. Every task-definition revision is reported, including a deregistered one, because each carries its own ARN and its own tags. Two things come with the row. scanECSClusters prefixed by account alone, so a us-east-1 caller was reported a us-west-2 cluster; all four scanners now share one ecsScanPrefix helper, per GetResources' own "located in the specified AWS Region for the account". The remaining Region-blind scanners are #937. And a ResourceTypeFilters type is now matched against the ARN's own delimited segment rather than as a prefix of the whole resource portion (#936). The old comparison was wrong in both directions: "ecs:task" selected a task definition, whose portion begins with "task", and "apigateway:restapis" selected nothing, because API Gateway's portion begins with a slash. One narrowing follows -- an S3 bucket named "bucket-logs" is no longer selected by "s3:bucket", since an S3 ARN embeds no type string for that filter to be "the same as". The four ECS key prefixes are named constants and colon-terminated, the sixth namespace to need that guard: each sits beside an index key whose value is a JSON array of names. ecsTagsToTaggingTags sorts by key in the one converter rather than at the four call sites, per #862. Closes #935. Closes #936.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…RDS case (#909) #909 is the earlier filing of #936 -- the same unanchored prefix comparison, found while implementing #835's RDS rows. Its acceptance criteria ask for two things #936's did not, and both are cheap enough to be worth having rather than leaving a duplicate half-satisfied. One row per reachable resource type: thirty-three, being the twenty-nine the twenty-eight GetResources scanners produce plus the four that only the named-ARN operations reach. The count is locked with require.Len, so a thirty-fourth type fails the test rather than going unexercised. The existing per-shape table proves the rule; this proves the rule covers the tree. And #909's prospective RDS case: cluster-pg, cluster-snapshot and cluster-endpoint are AWS resource types in their own right, all beginning with the string "cluster", so rds:cluster would have selected them. None is storable today, so the assertion is on the matcher, where it fails the moment one becomes storable. Closes #909.
This was referenced Sep 16, 2026
#835's fourth criterion asks that any type for which a tag genuinely cannot be written be listed in docs/services.md with the reason. ECS's three refused ARN shapes existed only as why strings in a guard test: a capacity provider (AWS lists it as taggable, substrate stores no such record), the documented short service ARN, and a task-definition ARN with a non-numeric revision. A container instance takes the capacity provider's reason. Part of #835.
This was referenced Sep 16, 2026
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.
Closes #935.
Closes #936.
Closes #909.
The ECS row (#935) — the last of #835
scanECSClusterswas the ECS namespace's only descriptor, soGetResourcesreported a cluster andnothing else. A tag written to a service, a task or a task definition through
TagResources— whichhas worked since v0.115.0, and reads back through ECS's own
ListTagsForResource— was invisible tothe tagging API's own inventory call. A caller asking "which of my resources carry this tag?" was
answered "none" about a resource the same API had just tagged.
Three new descriptors (
scanECSServices,scanECSTasks,scanECSTaskDefinitions) bring the ECSnamespace to four and the scanned set to twenty-eight resource types. With this, all eleven rows of
#835 meet its five acceptance criteria, so #835 closes with it.
A task is in scope alongside the two types #835's table names:
ecsTagStateKeyalready resolved atask ARN, so a tag could be written to one and read back nowhere, and AWS lists tasks first among the
taggable ECS resources — "There are multiple ways that Amazon ECS tasks, services, task
definitions, and clusters are tagged". Leaving it out would have left the row's own defect behind in
a third of the namespace.
Two decisions the task-definition scanner records rather than assumes:
RegisterTaskDefinitionaccepts tags perrevision and
ecsTagStateKeysplits a{family}:{revision}ARN to reach exactly one of them, soreporting only the newest would hide a tag the tagging API itself wrote to an older one.
INACTIVE) revision is reported too. AWS's tagging page says nothing aboutderegistration, and such a revision still answers
DescribeTaskDefinition, so it is still anobservable resource.
Region scope came with the row, not after it
scanECSClustersprefixed its scan by account alone, so aus-east-1caller was reported aus-west-2cluster. Had that been left, ECS would have answered one caller cross-Region aboutclusters and same-Region about the three new types — a worse state than either answer.
GetResourcessettles which is right in its opening sentence: it "[r]eturns all the tagged or previously tagged
resources that are located in the specified AWS Region for the account". All four scanners now go
through one
ecsScanPrefixhelper so they cannot disagree about scope.The same Region blindness remains in fourteen other scanners, with a cross-account variant in three.
That is #937, filed rather than fixed piecemeal here, and
ecsScanPrefix's doc comment says so.The colon-terminated guard, four times over
The four key prefixes are now named constants shared with the key builders in
ecs_plugin.go, and allfour are colon-terminated:
cluster:,taskdef:,service:,task:. Each sits beside an indexkey in the same namespace —
cluster_names:,taskdef_families:,taskdef_revisions:,service_names:,task_ids:— whose value is a JSON array of names. A prefix without the colon liststhose too and then drops them silently when the unmarshal into a resource type fails, which is the
failure mode that hides a defect by making the count right for the wrong reason. ECS is the sixth
namespace to need the guard and the first to need it four times. (
task:does not collide withtaskdef:; they differ at position 5.)ecsTagsToTaggingTagsalso sorts by key now, in the one converter rather than at each of the fourcall sites, so no ECS scanner can report the order tags happened to be written in (#862).
The filter fix (#936) — and why it had to ship with the row
matchesResourceTypecompared a filter's type half withstrings.HasPrefixagainst the ARN's wholeresource portion. AWS pins what the type means from two directions — "[s]pecifying a resource type of
ec2:instancereturns only EC2 instances" and "[t]he string for each service name and resourcetype is the same as that embedded in a resource's Amazon Resource Name (ARN)" — and the prefix
comparison broke the first in both directions:
ecs:taskselected a task definition, whose resource portion istask-definition/{family}:{revision}and therefore begins with the stringtask. A caller couldnot express "tasks only" at all — which is why the selectivity assertions for the row above could
not have been written honestly against it.
apigateway:restapisselected nothing. AWS publishes the ARN asarn:{partition}:apigateway:{region}::/restapis/{api-id}, so the resource portion begins with aslash that a prefix comparison against
restapiscannot see past. This one was already known andworked around in a comment in
TestTagging_GetResources_APIGatewayrather than filed; that commentis now an assertion.
The type is taken as the segment the ARN itself delimits, with one leading slash stripped first:
instance/i-abc123instancestateMachine:hellostateMachinetask-definition/sidecar:3task-definition/restapis/abc123restapismy-bucketmy-bucket(S3 embeds no type)This is the anchored-segment rule of #910 and #918 applied one layer up. Those fixed
strings.Contains(arn, ":stateMachine:")andstrings.LastIndex(arn, "distribution/")in the ARNresolvers, on the ground that a resource type must be matched against the ARN's own delimited
segment. The filter matcher is the one comparison of that kind whose left-hand side comes from the
caller, and it was in neither pass.
One narrowing a consumer may notice, recorded under
### Changed: an S3 bucket ARN isarn:aws:s3:::{name}and embeds no type string, so a bucket namedbucket-logsused to matchs3:bucketby accident of its first six characters (andassetsnever did). The service-only filters3is what reaches a bucket, as it always was.Corrections carried here
CHANGELOG.md("Two of the eleven rows; nine remain","The third … eight remain", and three more). The running tally has undercounted since feat(tagging): reach an ACM certificate and a CloudFront distribution (#835) #920 —
arithmetic on eleven that overlooked five rows already delivered — and the correction is on the
record in #835's own comment. Each entry now
states how many rows are complete rather than an ordinal.
docs/services.md's "Eight of the eleven … Three rows remain: a Step Functions activity and anRDS DB cluster and DB subnet group" — all three had already shipped (fix(stepfunctions): tag the resource the ARN names, in the shape AWS publishes (#910) #911, fix(rds): tag a DB cluster and subnet group through the ARN RDS reports (#835) #908).
TagResources/GetResourcesdifference, which is now EFS access points and Glue's other three types alone.
### Fixedentry saidTaggingPlugin.resolveARN"has nocloudfrontarm"; feat(tagging): reach an ACM certificate and a CloudFront distribution (#835) #920 gave it one later in the same cycle. Theentry now says what happened, and the guard-table row it cited is test(tagging): three rows of the wrong-type ARN guard now resolve, so they pass for a reason the table does not claim #939, filed here rather than
fixed, because deciding what that row should assert instead means first establishing which
FailureInfo.ErrorCodeAWS reports for a resolvable ARN naming a resource that does not exist.Tests
Two new files, both entirely wire-driven through
emulator.StartTestServer— nothing writes statedirectly, per #765.
emulator/tagging_ecs_test.go: all four types reported and carrying their tag; a tag readable throughboth APIs in both directions for each of the three new types; a
ResourceTypeFiltersentryselecting only its own type (five subtests); neither Region reporting the other's identically-named
resources; the exact-set assertion that no index key is reported as a resource; both revisions of one
family reported with their own tags; and reported tags in key order.
emulator/tagging_type_filter_test.go: one case per ARN shape in the scanned set, each with a filterthat must select and a strict-prefix filter that must not; the service check ahead of the type check;
the OR across the filter list; and the arity guard on a malformed ARN. It goes through a new
ResourceTypeMatchesForTestexport, because two of the six shapes — an S3 bucket namedbucket…, amalformed ARN — cannot be created through the wire at all.
Load-bearing against
origin/main: with only a minimal export stub injected, the two files failwith 21
FAILlines across all 8 new top-level tests. Three type-filter tests and theecs:clustersubtest pass on main; those are deliberate regression guards on already-correctbehaviour.
#909's two extra criteria
TestTaggingTypeFilter_EveryReachableTypeIsSelectedByItsOwnNameasserts the rule once per reachableresource type rather than once per ARN shape: thirty-three rows, being the twenty-nine the
twenty-eight
GetResourcesscanners produce (scanIAMEntitiesyields both a user and a role) plus thefour that only
TagResources/UntagResourcesreach — an EFS access point and Glue's job, crawler andconnection. The row count is locked with
require.Len, so a thirty-fourth type fails the test ratherthan going unexercised.
TestTaggingTypeFilter_ARDSClusterFilterDoesNotSelectAClusterParameterGrouppins #909's prospectivecase. AWS's RDS ARN table gives
cluster-pg,cluster-snapshotandcluster-endpointas resourcetypes in their own right, all three beginning with the string
cluster. None is storable today — theRDS resolver refuses all three segments — so the assertion is on the matcher, where it fails the moment
one becomes storable.
Verification
The nine-command gate, all green, from the repo root:
#835's fourth criterion
The one criterion #835 was still short of when the scanner landed: "any type for which a tag
genuinely cannot be written is listed in
docs/services.mdwith the reason." ECS's refusals existedonly as
whystrings intagging_arn_guards_test.go, which is not where a consumer looks. They arenow a table in the tagging section — a capacity provider (AWS lists it among the taggable ECS
resources, substrate stores no such record, so there is nothing to read a tag back from), AWS's
documented short service ARN (it names no cluster, so it identifies no record; the long
service/{cluster}/{name}form is what carries a tag), and a task-definition ARN whose revision isnot an integer — with a container instance taking the capacity provider's reason, and with absence
(
ResourceNotFoundException) distinguished from shape.