Skip to content

feat(cfn): stamp the twelve resource types #835 unblocked (#819) - #1040

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/819-cfn-stamp-group3b
Sep 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/819-cfn-stamp-group3b

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Group 3's second half is implemented and about to land. Three of this issue's own premises turned out
to be wrong or stale, and one acceptance row cannot be met, so both are on the record here before the
PR rather than implied by the diff.

What ships: twelve types, taking the stamp to 38 across 20 services. A KMS key and replica key, a
Secrets Manager secret, an SNS topic, an SSM parameter, an ACM certificate, a CloudFront distribution,
a Step Functions activity, an ECS service and task definition, and an RDS DB cluster and DB subnet
group. Each is asserted by reading the tag back through the owning service's own tag call, per
#765's criterion — ListResourceTags for KMS, ListTagsForCertificate for ACM, and DescribeSecret
for Secrets Manager, which publishes no tag-reading operation of its own (#929). Because
cfnResolveStampTarget also drives #764's propagation, all twelve gain stack-tag propagation with the
same change.

Correction 1 — this issue predicted ECS's service and task definition needed "a table line, not a
writer". A table line is exactly what they cannot have.
ecsTagStateKey builds a four-segment key
— service:<account>/<region>/<cluster>/<name> and taskdef:<account>/<region>/<family>/<revision> —
and neither the cluster nor the revision appears in the physical ID. Both are in the ARN, so both
resolve through ECS's own key builder rather than from the regional table.

Correction 2 — seven of the twelve fail the second condition, not the first. The blocker recorded
here was the missing mergeResourceTags arm, which #835 supplied for all seven namespaces. But once
that was gone, only five of the twelve could join cfnRegionalStampKinds; the other seven needed a
bespoke resolver arm because the deployer's PhysicalID is not the identifier the plugin keys on:

  • A KMS key's, a secret's and a topic's physical ID is an ARN where the record's key holds a bare
    ID or name. Each resolves through its own service's resolveARN, so the stamp and the service's tag
    call cannot disagree about which record is named.
  • A distribution's key carries no Region — CloudFront is global and its ARN's Region field is empty.
  • A parameter's key carries the leading / that PutParameter adds and the physical ID does not.
  • ECS's two, per correction 1.

Correction 3 — the sibling-truncation worry recorded here is gone. #835's arms merge raw JSON
behind a colon-terminated guard, so statesNamespace is safe for an activity: key and rdsNamespace
for a dbcluster:/dbsubnetgroup: one. No switch arm was needed on that account.

What remains, and why this issue stays open: AWS::Config::ConfigRule. It is the one genuine
writer gap left. Config keeps a rule's tags in a side-car record (cfgsvcTagsKey,
configservice_types.go) whose whole document is the tag map, so neither
mergeRecordStringMapTags nor mergeRecordTagListTags fits — both look for a tag member inside a
record — and mergeResourceTags has no configServiceNamespace arm to hold one. cfgsvcSaveTags also
deletes the document when it empties, so there is frequently no record to merge into at all. A Config
arm would have to create the side-car, not merge into it, which is a different contract from every
other arm and worth deciding deliberately rather than bolting on here.

That is the last acceptance row, so the issue stays open with this comment rather than being closed by
the PR.

One defect found while doing this, fixed in the same PR and worth naming separately. A KMS key's
stored tags read back as nil from cfnRecordTags, because it decoded a map, an ECS-style
key/value list and an EFS-style Key/Value list — and KMS spells its members
TagKey/TagValue, AWS's own naming for the KMS Tag shape and unique in the tree. nil is
indistinguishable from a resource carrying no tags, and both of the reconciliation's safeguards hinge
on the existing set: a caller's own value is preserved only by comparing it against what the stack
previously propagated, and a stack tag is removed only when the stored value still matches. So both
failed together, silently, and only on a second deployment.

Worth recording how that one is tested, because the obvious test cannot be written: an UpdateStack
mints a new KMS key, so the reconciliation never revisits the record a caller could have tagged,
and no deployment sequence reaches the shape at issue. Of the twelve, only a topic and a parameter are
list-shaped and idempotent on re-create, so they carry the end-to-end clobber/removal assertion
(an ECS service keeps its ARN across an update but has its record rebuilt, which wipes the caller's
tag before the reconciliation runs). KMS's spelling is covered by a unit test through an exported
accessor, with that reason stated at the accessor.

The `aws:cloudformation:*` stamp now reaches a KMS key and replica key, a
Secrets Manager secret, an SNS topic, an SSM parameter, an ACM certificate, a
CloudFront distribution, a Step Functions activity, an ECS service and task
definition, and an RDS DB cluster and DB subnet group — 38 CFN resource types
across 20 services. The same resolver drives #764's propagation, so a
`CreateStack` tag reaches all twelve with it.

These twelve were held out by one condition: substrate's shared tag writer had
no arm reaching their namespace and key prefix, so there was nowhere for a stamp
to land that the owning service would ever read. #835 supplied all seven arms.
Every type is asserted by reading the tag back through the owning service's own
tag call, per #765's criterion — `ListResourceTags` for KMS,
`ListTagsForCertificate` for ACM, `DescribeSecret` for Secrets Manager, which
publishes no tag-reading operation of its own (#929).

Seven of the twelve could not be table entries, and #819's own prediction that
ECS needed "a table line, not a writer" is corrected: a table line is exactly
what it cannot have. `ecsTagStateKey` builds a four-segment key whose cluster
and revision appear only in the ARN. A KMS key's, a secret's and a topic's
physical ID is an ARN where the record's key holds a bare ID or name; a
distribution's key carries no Region; a parameter's carries the leading slash
`PutParameter` adds.

Also fixes a defect found while doing it: `cfnRecordTags` read a KMS key's
stored tags as nil, because KMS spells its members `TagKey`/`TagValue` where
every other record in the tree uses `Key`/`Value` or `key`/`value`. nil is
indistinguishable from an untagged resource, and both of the reconciliation's
safeguards hinge on the existing set — so a caller's own tag was clobbered and a
removed stack tag was never removed, silently and only on a second deployment.

`AWS::Config::ConfigRule` remains unstamped and is the one genuine writer gap
left, so #819 stays open. Config keeps a rule's tags in a side-car record whose
whole document is the tag map, which neither merge helper fits, and the side-car
is deleted when it empties.

Part of #819.
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/cfn_resource_tags.go 89.47% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit f84c12b into main Sep 17, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/819-cfn-stamp-group3b branch September 17, 2026 19: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