Repository navigation
feat(ec2): CreateTags reaches every taggable resource type (#708) - #721
Merged
Merged
Conversation
Five ID prefixes were silently ignored: a CreateTags naming an ami-, lt-, fleet-, pg- or key- ID answered <return>true</return> and wrote nothing. Each was well-formed and named a resource substrate stores, so a caller had no way to tell — the answer is the one a successful call gives. ec2TaggableResource now resolves fifteen prefixes and ec2TagScanTargets reports the same fifteen, so DescribeTags and CreateTags cover exactly the same set; previously three types could be read and not written, and placement-group and key-pair could be neither. A launch template's own tags were settable by no path at all: the TagSpecification CreateLaunchTemplate read lives inside LaunchTemplateData and is scoped to what a launch creates. The top-level TagSpecification.N scoped to launch-template is now read as well. EC2KeyPair gained a Tags field, CreateKeyPair/ImportKeyPair/ CreatePlacementGroup honour TagSpecification.N, and DescribeKeyPairs/ DescribePlacementGroups render tagSet. An ID whose prefix names no taggable type is now refused with InvalidID over every ResourceId.N before the first tag is applied, rather than ignored. A well-formed prefix naming nothing stays a no-op at 200. Seven responses omit tagSet for an untagged resource instead of rendering <tagSet></tagSet>, following AWS's own untagged examples; xml:"tagSet>item,omitempty" cannot express the absence, so they converged on the pointer wrapper #685 wrote for DescribeSubnets, now ec2TagSetXML. DescribeFleets keeps the old shape — its page publishes no example response — and DescribeSnapshots keeps its empty element, which its own page shows. Fixed alongside: an ami- and a snap- ID are authorized against the account-less ARN AWS documents, where the authorizer stamped the account on unconditionally and made an ARN-scoped Deny inert (#689's arm had it). Closes #708
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.
Closes #708
CreateTagsresolved ten ID prefixes and silently ignored the rest. A request naming anami-,lt-,fleet-,pg-orkey-ID answered<return>true</return>and wrote nothing — every one of the five was well-formed and named a resource substrate stores, so the answer was indistinguishable from success.ec2TaggableResourcenow resolves fifteen prefixes, andec2TagScanTargetsreports the same fifteen, soDescribeTagsandCreateTagscover exactly the same set. They did not: three types could be read and not written, andplacement-groupandkey-paircould be neither — both were absent from the scan too.Corrections to the issue body
tagsmember" — false for key-pair.EC2KeyPairhad noTagsfield. Added, spelled"tags"like every other record soapplyTagsToResourceandscanTagsfind it.DescribeTagsalready reports tags on all of them" — false for placement-group and key-pair. Neither was inec2TagScanTargets, and both are keyed by name, so the scan neededidMemberto read the ID out of the record rather than reporting the key's tail.TagSpecificationcreateLaunchTemplateread lives insideLaunchTemplateDataand is AWS's "tags for the resources that are created when an instance is launched" — a different parameter from the top-levelTagSpecification.N, "the tags to apply to the launch template on creation. To tag the launch template, the resource type must belaunch-template". Both are read now, each on its own scope.Two things the tests caught
xml:"tagSet>item,omitempty"cannot omit an element. encoding/xml writes the parent of a nested path even for a nil slice, so every untagged key pair, placement group and launch template answered<tagSet></tagSet>. AWS'sCreateLaunchTemplateExample 1 andCreatePlacementGroupExample 2 each create an untagged resource and neither response carries atagSetat all, whileCreateKeyPair's tagged example does. Fixed with a pointer-to-wrapper struct — whichec2_subnet_filters.gohad already discovered for #685, so the two converged on one sharedec2TagSetXMLrather than shipping the struct twice.Refusing inside the apply loop leaves a partially-tagged state.
ec2CheckTagResourceIDsruns over everyResourceId.Nbefore the first tag is written, so a request naming a good instance ID first and a bad ID second tags neither.TestEC2_CreateTags_RefusesBeforeTaggingAnythingfails against the refuse-in-the-loop shape.Behaviour changes
InvalidID/ 400 instead of<return>true</return>tagSetwhen a resource has no tagsami-andsnap-authorize against an account-less ARNarn:${Partition}:ec2:${Region}::image/${ImageId}is what AWS publishesDescribeFleetskeeps the empty element deliberately: its API reference page publishes no example response, so there is no untagged sample to follow and changing it would be substrate guessing rather than reading.DescribeSnapshotskeeps its present-but-empty element because its own page shows it. Each response answers to the page that documents it.Provenance
InvalidID's code and description are AWS's, but from the client-error table —API_CreateTags.htmlpublishes no operation-specific error at all. Naming the offending ID where AWS writes "The specified ID" is substrate's.CreateTagstakes a placement group by ID or by name is not settled by AWS. The ARN is by name andDescribePlacementGroupspublishes nogroup-idfilter, but the client-error table publishesInvalidPlacementGroupId.Malformed"in the formpg-xxxxxxxxxxxxxxxxx", which only an ID-taking operation can raise. Substrate accepts thepg-form and translates.Verification
gofmt/go build/go vet/golangci-lintclean;make testgreen with race; coverage 83.1% onemulator(82.4% total);make docs-reference docs-reference-check docs-versions; docs site builds with no missing anchors;test/e2egreen.The authz-layer suite went from nine resource types to all fifteen. Mutating the ARN builders — stamping the account onto
image/snapshot, and naming the placement group by ID instead of by name — turns exactly those three subtests red, so the new rows bite.A live AWS CLI run against a built binary confirms the wire shapes: tagged and untagged
CreateKeyPair/CreatePlacementGroup/CreateLaunchTemplate(untagged decode toTags: null, tagged to the tags),CreateTagsover all five new types followed byDescribeTagsreporting each under the rightresourceTypeand the ID the caller passed, theInvalidIDrefusal, andDeleteTagsclearing them again.