Skip to content

feat(cfn): the aws:cloudformation:* stamp reaches AWS Config (#819) - #1042

Merged
scttfrdmn merged 3 commits into
mainfrom
feat/819-config-stamp
Sep 17, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
feat/819-config-stamp

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

What

AWS::Config::ConfigRule and AWS::Config::ConfigurationRecorder now carry the three
aws:cloudformation:* keys, and a CreateStack tag propagates to both with them (#764). That takes
the stamp to 40 CFN resource types across 21 services and closes this issue's last acceptance row.

The recorder is one type more than #819 predicted. It named the rule alone, but TagResource's
ResourceArn enumerates both, a recorder records its ARN at deploy time exactly as a rule does, and a
template that declares Config declares both — so stamping one of the pair would have been the arbitrary
choice.

Why Config needed a writer rather than an arm in the shared one

Config keeps a resource's tags in a side-car record keyed by ARN whose whole document is the tag
map, rather than on the resource. That is deliberate: neither AWS's ConfigurationRecorder shape nor
its ConfigRule shape has a Tags member, and inventing one would emit a member AWS never emits
(#836). Both shared merge helpers look for a tag member inside a record, and here there is none to
merge into. Three consequences shape the arm, and each is asserted:

  • The stamp creates the side-car, where every other arm refuses a record that is absent.
  • The existence check is made against the resource, not the side-car, through the same lookup
    ListTagsForResource uses. Reading the side-car alone cannot tell "this rule has no tags" from
    "there is no such rule".
  • The key is the ARN, not the physical ID. A rule's physical ID is its name while its ARN names it
    by a hashed ConfigRuleId, and a recorder's ARN carries a minted RecorderId no API member holds, so
    both are read back from the service at deploy time; an ARN that could not be read leaves the resource
    unstamped rather than stamped under a guess.

The reconciliation, and why Config is the one type that can prove it works

The propagation arm reads the side-car directly. Reading through the shared reader would find neither a
tags nor a Tags member and report the resource as untagged — the KMS defect #819's second half
fixed, whose two failures arrive together: a caller's own tag of the same name is clobbered, and a
withdrawn stack tag is never removed.

Ten of the previous twelve could not carry that assertion end to end, because an UpdateStack
re-creates every resource and a type whose create mints a fresh identity is never revisited at the
record a caller could have tagged. Both Config types re-mint their ARN from the name, and both Puts
leave the side-car alone on an update — Config's own words, "Tags are added at creation and cannot be
updated with this operation" — so the identity survives and a directly-set tag is still there to
preserve. TestCFN_AConfigSideCarIsReadBeforeItIsReconciled deploys with two stack tags, tags both
resources directly through Config's own TagResource, then updates with one tag changed and the other
withdrawn, and asserts the caller's value survives and the withdrawn tag is gone. Substituting an
empty existing set for the side-car read makes it fail in both directions at once.

The delivery channel

AWS::Config::DeliveryChannel is asserted as the negative case rather than left untested.
TagResource's ResourceArn lists the nine resources Config can tag and a delivery channel is not
among them, the DeliveryChannel shape has no arn member to be named by, and substrate's deploy
records no ARN for it — so it deploys clean, is skipped in silence, and logs nothing. The count of
side-car records is what makes "skipped" distinguishable from "wrote something somewhere else"; a
warning-free log alone cannot.

The same fetch corrected one thing I had written and one comment already in the tree: the exclusion is
now justified by TagResource's enumeration, which is quotable, rather than by a claim about the
Service Authorization Reference's resource-type table.

Tests

emulator/cfn_stamp_config_test.go, three tests. Each tag is read back through Config's own
ListTagsForResource, per #765's criterion that a stamp written to a key the service does not read
satisfies a state assertion and no caller — the defect #826 found for SQS, #845 for DynamoDB and #943
for Lambda. The delivery channel's S3 precondition is established through S3's own wire calls
rather than by writing state, for the same reason. The one state read in the file is about absence —
a type the stamp skips writes nothing, and nothing cannot be read back through an API call.

Recorded rather than tested

Config's writer deletes the side-car when its last tag leaves, so an untagged resource stays
distinguishable from one holding {}. CloudFormation cannot reach that case: the three stamp keys are
written before the stack tags are reconciled, so a resource a stack touched always carries at least
three tags. The rule therefore lives with Config's own UntagResource, which can reach it, and
docs/services.md says so rather than the rule being restated where nothing could exercise it.

Verification

The nine-command gate, all green. Coverage holds at 85.1% emulator / 84.6% total.

Closes #819

`AWS::Config::ConfigRule` and `AWS::Config::ConfigurationRecorder` now carry
the three `aws:cloudformation:*` keys, and a `CreateStack` tag propagates to
both with them (#764). That takes the stamp to forty CFN resource types across
twenty-one services and closes #819's last acceptance row.

The recorder is one type more than the issue predicted. It named the rule
alone, but a recorder is equally taggable in AWS's reckoning — `TagResource`'s
`ResourceArn` enumerates both — and equally reachable, so stamping one of a
pair a template declares together would have been the arbitrary choice.

Config needed a writer of its own rather than an arm in the shared one, which
is why it outlasted the other twelve. It keeps a resource's tags in a side-car
record keyed by ARN whose whole document *is* the tag map, because neither
AWS's `ConfigurationRecorder` shape nor its `ConfigRule` shape has a `Tags`
member and inventing one would emit a member AWS never emits (#836). Both
shared merge helpers look for a tag member inside a record, and here there is
none to merge into. So the stamp creates the side-car where every other arm
refuses an absent record; the existence check is made against the resource
rather than the side-car, through the same lookup `ListTagsForResource` uses,
because reading the side-car alone cannot tell "this rule has no tags" from
"there is no such rule"; and the key is the ARN, not the physical ID.

The reconciliation reads the side-car directly, and Config is the one type in
#819 where both stack-tag safeguards can be shown to work end to end. Reading
through the shared reader would find neither a `tags` nor a `Tags` member and
report the resource as untagged — the KMS defect #819's second half fixed,
whose two failures arrive together: a caller's own tag of the same name is
clobbered and a withdrawn stack tag is never removed. Ten of the previous
twelve could not carry that assertion, because an `UpdateStack` re-creates
every resource and a type whose create mints a fresh identity is never
revisited at the record a caller could have tagged. Both Config types re-mint
their ARN from the name and both Puts leave the side-car alone on an update, so
the identity survives and a directly-set tag is still there to preserve.

`AWS::Config::DeliveryChannel` is asserted as the negative case rather than
left untested: `TagResource`'s nine supported `ResourceArn` types do not
include a delivery channel, the `DeliveryChannel` shape has no `arn` member to
be named by, and the deploy records none, so it deploys clean and is skipped in
silence with no warning logged. The delete-when-empty rule is unreachable from
CloudFormation — the three stamp keys are written before the stack tags are
reconciled — and is recorded in `docs/services.md` rather than tested.

Each tag is read back through Config's own `ListTagsForResource`, per #765's
criterion, and the delivery channel's S3 precondition is established through
S3's own wire calls rather than by writing state.

Closes #819
@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.17647% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/configservice_tags.go 87.50% 6 Missing ⚠️
emulator/configservice_types.go 86.66% 2 Missing ⚠️
emulator/cfn_stack_tag_propagation.go 95.45% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…819)

Both Config arms open with two guards no template can reach: a recorder's and a
rule's ARN is read back from the service at deploy time, so a resource that
deployed has one and resolves. They are contracts rather than dead code, and
the contract belongs to the deployer — `(false, nil)` is rendered as "skipped
in silence" where an error is logged as a failure to stamp. The unresolvable
case has a real occasion behind it: a caller can delete a Config rule through
Config's own `DeleteConfigRule` between two runs against one event stream, and
a reconciliation that failed the stack over it would make the stack
undeployable over a resource somebody else removed.

Asserted directly through two exported accessors, following the reason
`CFNDecodeRecordTagsForTest` already gives for the same kind of shape.

Also corrects that accessor's own doc comment: the end-to-end assertion for the
KMS spelling goes through an SNS topic and an SSM parameter, not an ECS
service — an ECS service keeps its ARN across an update but has its record
rebuilt, which is why it could not carry the assertion.
The other half of the two guards, and the reason neither may report a store
problem. A resource that is not there and a resource that could not be read are
different answers: the first is `(false, nil)`, which the deployer renders as a
silent skip, and the second is `(true, err)`, which it logs as a failure to
stamp. Collapsing the second into the first would leave a Config resource
untagged with nothing anywhere saying so — the tag simply missing, on a stack
that deployed clean.

Both directions, because they fail in different places: the read is the
resolution, and the write is the side-car save that happens after a resource has
been found. The double embeds `emulator.StateManager` and scopes its write
failure to the `config` namespace, so the deploy that sets the fixture up is not
the thing that breaks.
@scttfrdmn
scttfrdmn merged commit 3e60949 into main Sep 17, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/819-config-stamp branch September 17, 2026 21:42
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.

CloudFormation: the resource types the aws:cloudformation:* stamp still skips

1 participant