Repository navigation
feat(cfn): the aws:cloudformation:* stamp reaches AWS Config (#819) - #1042
Merged
Merged
Conversation
`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 Report❌ Patch coverage is
📢 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.
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.
What
AWS::Config::ConfigRuleandAWS::Config::ConfigurationRecordernow carry the threeaws:cloudformation:*keys, and aCreateStacktag propagates to both with them (#764). That takesthe 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'sResourceArnenumerates both, a recorder records its ARN at deploy time exactly as a rule does, and atemplate 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
ConfigurationRecordershape norits
ConfigRuleshape has aTagsmember, 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:
ListTagsForResourceuses. Reading the side-car alone cannot tell "this rule has no tags" from"there is no such rule".
by a hashed
ConfigRuleId, and a recorder's ARN carries a mintedRecorderIdno API member holds, soboth 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
tagsnor aTagsmember and report the resource as untagged — the KMS defect #819's second halffixed, 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
UpdateStackre-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_AConfigSideCarIsReadBeforeItIsReconcileddeploys with two stack tags, tags bothresources directly through Config's own
TagResource, then updates with one tag changed and the otherwithdrawn, 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::DeliveryChannelis asserted as the negative case rather than left untested.TagResource'sResourceArnlists the nine resources Config can tag and a delivery channel is notamong them, the
DeliveryChannelshape has noarnmember to be named by, and substrate's deployrecords 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 theService Authorization Reference's resource-type table.
Tests
emulator/cfn_stamp_config_test.go, three tests. Each tag is read back through Config's ownListTagsForResource, per #765's criterion that a stamp written to a key the service does not readsatisfies 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 arewritten 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, anddocs/services.mdsays 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