Repository navigation
feat(cfn): stamp the twelve resource types #835 unblocked (#819) - #1040
Merged
Merged
Conversation
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 Report❌ Patch coverage is
📢 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.
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 —
ListResourceTagsfor KMS,ListTagsForCertificatefor ACM, andDescribeSecretfor Secrets Manager, which publishes no tag-reading operation of its own (#929). Because
cfnResolveStampTargetalso drives #764's propagation, all twelve gain stack-tag propagation with thesame 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.
ecsTagStateKeybuilds a four-segment key—
service:<account>/<region>/<cluster>/<name>andtaskdef:<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
mergeResourceTagsarm, which #835 supplied for all seven namespaces. But oncethat was gone, only five of the twelve could join
cfnRegionalStampKinds; the other seven needed abespoke resolver arm because the deployer's
PhysicalIDis not the identifier the plugin keys on:ID or name. Each resolves through its own service's
resolveARN, so the stamp and the service's tagcall cannot disagree about which record is named.
/thatPutParameteradds and the physical ID does not.Correction 3 — the sibling-truncation worry recorded here is gone. #835's arms merge raw JSON
behind a colon-terminated guard, so
statesNamespaceis safe for anactivity:key andrdsNamespacefor a
dbcluster:/dbsubnetgroup:one. Noswitcharm was needed on that account.What remains, and why this issue stays open:
AWS::Config::ConfigRule. It is the one genuinewriter 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 neithermergeRecordStringMapTagsnormergeRecordTagListTagsfits — both look for a tag member inside arecord — and
mergeResourceTagshas noconfigServiceNamespacearm to hold one.cfgsvcSaveTagsalsodeletes 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
nilfromcfnRecordTags, because it decoded a map, an ECS-stylekey/valuelist and an EFS-styleKey/Valuelist — and KMS spells its membersTagKey/TagValue, AWS's own naming for the KMSTagshape and unique in the tree.nilisindistinguishable 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
UpdateStackmints 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.