Skip to content

feat(ec2): a volume can be tagged, reports its tags, and is filterable by them (#670) - #681

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/670-volume-tags
Aug 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/670-volume-tags

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #670.

A volume was the one taggable EC2 resource with no working tagging path at all, and
every call on it answered success:

  • CreateVolume accepted TagSpecification.N and stored nothing.
  • CreateTags on a vol- ID answered <return>true</return> and wrote nothing —
    the issue's "may already work" premise, traced end to end and false.
  • DescribeVolumes rendered no tagSet and supported no tag filter.
  • EC2Volume.Tags existed, with nothing ever writing to it.

So an IaC consumer's tag-everything convention appeared to hold and nothing could
observe that it had not — the same store-and-hide shape #471 closed for a launch
template's tags.

What changed

Four paths, all now real:

Path Behaviour
CreateVolume applies its volume-scoped TagSpecification.N, echoes a tagSet
RunInstances applies its volume-scoped tags to every volume the launch makes, synthesized root included
A launch template volume-scoped tags reach the launch on their own merge gate, independent of the instance scope
CreateTags/DeleteTags accept a vol- ID like any other taggable ID

Both tag rules apply on all four — reserved aws: prefix and the 50-tag limit, since
AWS documents no volume-specific constraint. On a launch the check runs before the
launch loop
: a volume is written after its own instance, so a refusal inside the loop
would leave instance 1 of a MaxCount=2 launch behind.

DescribeVolumes gains tag:<key> and tag-key — exactly the two tag filters AWS
documents for the operation, out of 20; there is no tag-value. Its hand-rolled
Filter.N loop, whose nine map[string]bool sets could not express a filter whose key
is part of its name, is replaced by the shared extractEC2Filters walk plus a match
function, per the issue's "rather than a second hand-rolled implementation".

CreateVolume also stopped discarding Iops and Throughput, which EC2Volume stored
and DescribeVolumes rendered — so a provisioned volume created that way read back as an
unprovisioned one, while the same values through a launch mapping did not.

The one risky piece, and the mitigation

The template's volume scope is a new VolumeTagSpecifications field, not a widened
TagSpecifications. Adding a ResourceType discriminator to the existing persisted
field would unmarshal every template already in an event log without error — into an
element with an empty resource type and no tags — so every stored template would
silently start launching untagged instances. That is deterministic replay broken by a
change that compiles. EC2LaunchTemplateData.NetworkInterfaces already uses this split
for the same reason.

Fail-before proof

go test ./emulator/ -run 'TestEC2_(CreateVolume|CreateTags_OnVolume|DescribeVolumes|RunInstances_Volume|LaunchTemplate_Volume)', on main at e111039 with the new test file added and no other change:

--- FAIL: TestEC2_CreateVolume_TagOnCreate
--- FAIL: TestEC2_CreateVolume_ScopeIsHonored
--- FAIL: TestEC2_CreateVolume_EmptyTagSetIsPresent
--- FAIL: TestEC2_CreateVolume_IopsAndThroughput
--- FAIL: TestEC2_CreateVolume_TagRulesRefused (all 3 subtests)
--- FAIL: TestEC2_CreateVolume_TagLimitAllowsExactly50
--- FAIL: TestEC2_CreateTags_OnVolume
--- FAIL: TestEC2_CreateTags_OnVolumeChecksTheLimit
--- FAIL: TestEC2_DescribeVolumes_TagFilters (5 of 7 subtests)
--- FAIL: TestEC2_RunInstances_VolumeTagSpecifications
--- FAIL: TestEC2_RunInstances_VolumeTagsAreFilterable
--- FAIL: TestEC2_RunInstances_VolumeTagRulesRefused
--- FAIL: TestEC2_LaunchTemplate_VolumeTagSpecifications
--- FAIL: TestEC2_LaunchTemplate_VolumeTagsAreReplacedNotMerged

Illustrative: the reserved-key and over-long-key CreateVolume rows returned 200 and
left vol-52fb17a02eac01a2 / vol-55e237ecad5b242a behind; _IopsAndThroughput got 0
for both; _VolumeTagsAreFilterable got map[string]string{}.
TestEC2_DescribeVolumes_ExistingFiltersStillWork passed before and after, which is
what a regression guard for the filter-loop replacement is for.

One existing assertion inverted

TestEC2_RunInstances_ReservedTagRejectionCreatesNothing's last case asserted the old
deliberate limit — a volume-scoped reserved key did not fail an instance launch,
because the scope was parsed nowhere and an unapplied specification was an unchecked one.
It now fails the launch, and the row asserts the refusal leaves no instance behind.

Provenance

  • The tagSet element carries no omitempty because AWS's second CreateVolume example
    renders <tagSet/> for an untagged volume, and an SDK tells present-but-empty ("no
    tags") from omitted ("unknown").
  • A tag:<key> filter with no value matches nothing — substrate's answer where AWS
    documents none (Using_Filtering says only that a filter value cannot be null, and
    offers tag-key for the any-value question). This follows DescribeInstances;
    describeImages, which treats it as tag-key, is deliberately left alone and filed as
    a follow-up rather than changed in this PR.
  • An unrecognized filter name is still dropped. The comment claiming that was "the
    behavior every other EC2 filter site has" is corrected: three behaviours exist in the
    package — drop (volumes, snapshots), match-nothing (ec2InstanceMatchesFilter), and
    refuse (describeInstanceTypeOfferings, which is what real EC2 does).

Compatibility

CreateVolume and DescribeVolumes responses gain tagSet, iops and throughput — a
byte-exact response assertion will see them. A RunInstances or CreateLaunchTemplate
naming a reserved key or more than 50 tags in a volume-scoped TagSpecification now
fails where it previously succeeded with those tags dropped.

Verification

gofmt -l . ; go build ./... ; go vet ./... ; golangci-lint run ./...   # clean, 0 issues
make test                                                             # race, all green
make coverage                                                         # emulator 82.8%
make docs-reference docs-reference-check docs-versions                 # clean
npm --prefix docs run build                                            # build complete
go vet -C test/e2e ./... && go test -C test/e2e ./...                  # ok

The SDK-tier journey is TestJourney_EC2VolumeTags: CreateVolume with tags and
provisioned performance, a launch tagging both scopes, tag:Env alone and AND-combined
with attachment.instance-id, a CreateTags/DeleteTags round trip on the volume, and
a reserved-key refusal that leaves no instance behind.

…e by them (#670)

A volume was the one taggable EC2 resource with no working tagging path, and
every call on it answered success: CreateVolume accepted TagSpecification.N and
stored nothing, CreateTags on a vol- ID answered <return>true</return> and wrote
nothing, DescribeVolumes rendered no tagSet and matched no tag filter, and
EC2Volume.Tags existed with nothing ever writing to it.

Four paths are now real — CreateVolume, RunInstances' volume scope, a launch
template's volume scope, and CreateTags/DeleteTags on a vol- ID — with both tag
rules applied on each, checked before the launch loop so a refusal leaves no
instance behind. describeVolumes' hand-rolled nine-set filter loop is replaced
by the shared extractEC2Filters walk plus a match function, which is what makes
tag:<key> expressible, and CreateVolume stopped discarding Iops and Throughput.

The template's volume scope goes in a new VolumeTagSpecifications field rather
than widening the persisted instance-scoped one, which would have silently
untagged every template already in an event log.
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.47899% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/ec2_plugin.go 95.00% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 7007bb6 into main Aug 20, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/670-volume-tags branch August 20, 2026 22:39
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.

ec2: a volume cannot be tagged at creation and cannot report or be filtered by its tags

1 participant