Repository navigation
feat(cfn): a stack records its own tags, and DescribeStacks reports them (#764) - #825
Merged
Merged
Conversation
…hem (#764) CreateStack's and UpdateStack's Tags.member.N was decoded by nothing at all: a caller sending --tags Key=team,Value=platform got a 200 and a stack that reported no tags, so a cost-allocation or policy assertion keyed on a stack tag had nothing to read. CFNStackState gains a Tags field and cfnStackItem a Tags member, reported sorted by key as parameters and outputs already are. The update semantics are AWS's, and they are why the tags are a map that can be absent rather than a list: omitting the parameter preserves, an empty list clears, and sending members replaces the set wholesale. UpdateStack takes an options struct for the first time. Validation is against the Tag data type's own constraints — 50 tags, key 1-128, value 1-256, counted in characters. Two divergences are AWS's own and asserted rather than smoothed over: a stack tag's value may not be empty where IAM's and ELBv2's may, and the reserved aws: prefix is matched case-insensitively, which CloudFormation alone documents. The ValidationError/400 is substrate's choice and recorded as such.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
5 tasks
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.
CreateStack's andUpdateStack'sTags.member.Nwas decoded by nothing at all. A callersending
--tags Key=team,Value=platformgot a 200 and a stack that reported no tags, so acost-allocation or policy assertion keyed on a stack tag had nothing to read, and there was no
way to tell a tagged stack from an untagged one.
Part of #764 — this half records and reports a stack's tags. Propagating them onto the
resources the stack creates is the other half and stays open.
What changed
CFNStackStategains aTagsfield andcfnStackItemaTagsmember, reported sorted bykey as
ParametersandOutputsalready are, so a response is byte-identical across runs.UpdateStacktakes an options struct for the first time, which is the one non-obvious costhere; a rollback of a failed update restores the tags the stack had, since a rollback converges
on the stack as it was.
The update semantics are AWS's, and they are why the tags are a map
Three different requests, not two:
UpdateStacksendsTagsparameterTags=(an empty list)Tags.member.NThe distinction is observable on the wire because the query protocol serialises an empty list
as a bare
Tags=— botocore's_serialize_type_list, "The query protocol serializes emptylists" — so
--tags '[]'arrives with the parameter present and no members, where a requestthat omits it arrives without it. A
map[string]stringwhere nil ≠ empty is what carries thatthrough to the resolver.
Two divergences, both AWS's own
Tagmodel's minimum is 1 and the member isRequired: Yes, where IAM's and ELBv2's tag values document a minimum of 0. SoKey=teamwith no value is refused by CloudFormation and accepted by those two.
aws:prefix is matched case-insensitively. CloudFormation is the onlyservice in substrate that does, because it is the only one whose documentation says so: "The
aws:prefix is reserved for AWS use. This prefix is case-insensitive."AWS:ownerisrefused as a stack tag and stays an ordinary caller tag in EC2, ELBv2 and IAM. The prefix is
refused in a key only — of a value carrying it AWS says merely that "you can't update or
delete the tag", a consequence rather than a refusal.
No character set is enforced: the
Tagmodel publishes noPatternfor either member, unlikeIAM's and AWS Config's, and inventing one would refuse requests AWS accepts. The console page's
127 and 255 lose to the model's 128 and 256, and
docs/services.mdrecords the disagreement.Provenance
The
ValidationError/400 is substrate's choice, not AWS's. Neither operation's Errors listnames a code for a bad tag, and substrate's two precedents disagree — EC2 invents
InvalidParameterValue, ELBv2 accepts silently.ValidationErroris what the plugin alreadyanswers every other parameter refusal with. The refusal is of the whole request: a create with
one bad tag leaves no stack behind, and a refused update changes nothing. Validation lives on
the deployer's options rather than at the wire layer, so an in-process
Clientdeploy is heldto the same limits as an HTTP request.
Compatibility
CreateStack/UpdateStackstart refusing anaws:-prefixed tag key (any case), an empty keyor value, a key over 128 or a value over 256 characters, and more than 50 tags — where the tags
were previously ignored entirely.
DescribeStacksgains aTagsmember.CFNStackStategainsa field, additively: a stack recorded by an earlier version reads back with no tags.
Verification
Fail-before with the decoder neutered: 4 tests / 12 subtests red, and only
TestCFN_AStackWithNoTagsReportsAnEmptyTagListgreen — correctly, since it asserts theno-tags case. Pass-after clean.
CreateChangeSetstill dropsTags.member.N, filed as #824.