Repository navigation
Description
Context
v0.103.0 (#666) made RunInstances parse and materialize BlockDeviceMapping.N.*. It
validates none of it: a mapping that real EC2 would refuse with InvalidBlockDeviceMapping
is accepted and produces a volume.
The tolerant reads #666 chose on purpose (an unparseable number reads as zero rather than
failing the launch, matching what ec2ParseNetworkInterface does for DeviceIndex) are
part of what this issue should revisit now that there is state to validate against.
Cases AWS refuses that substrate currently accepts:
- A data volume naming neither
Ebs.VolumeSizenorEbs.SnapshotId. The
EbsBlockDevicereference is explicit: "You must specify either a snapshot ID or a volume
size." Substrate silently defaults to 8 GiB. Ebs.VolumeSizesmaller than the snapshot's size.- A
VirtualNamealongsideEbs.*members on one mapping — a contradictory mapping. EC2: RunInstances' inline BlockDeviceMapping.N.Ebs.* is parsed nowhere and never reaches DescribeVolumes #666
deliberately honors the EBS half rather than dropping a volume the caller sized, which was
the right call when the alternative was silence, but AWS refuses it outright. Ebs.Iopson a volume type that does not take provisioned IOPS, andEbs.Throughputon
anything butgp3.- A size outside the type's documented range, and an IOPS value outside it.
- A duplicate
DeviceNameacross two mappings.
Why it was deferred out of #666
Validation needs the state it validates to exist first: before #666 there was no parsed
mapping to check and no volume to compare a snapshot size against. The fix also has a
compatibility edge that deserves its own release note — a request substrate accepted in
v0.103.0 will start failing — which is a poor fit for a PR whose headline is "the parameter
is no longer discarded".
Acceptance criteria
- Each case above is refused with
InvalidBlockDeviceMappingand a message checked
against AWS's own wording where it is observable, or documented as substrate's own
where it is not (per the house provenance rule). - The error code and HTTP status are verified against the EC2 API reference, not recalled.
- Validation happens before any volume is written, so a refused launch leaves no partial
state — asserted by a test that refuses and then lists volumes. - A launch template carrying an invalid mapping is refused at
RunInstancestime, and it
is decided and documented whetherCreateLaunchTemplaterefuses it too (AWS validates
some template fields lazily; check rather than assume). - The tolerant numeric reads are revisited: either an unparseable
VolumeSizebecomes an
error, or the tolerance is documented as deliberate with the reason. -
docs/services.md— the "not modeled" paragraph of the launch-time storage subsection
loses this item. -
CHANGELOG.mdunder## [Unreleased], with a compatibility note: a mapping v0.103.0
accepted may now be refused.
Activity
scttfrdmn commentedon Aug 20, 2026
Moved to milestone v0.105.0. v0.104.0 ships the #662 privilege-boundary fix alone, matching how #660 shipped as v0.102.0 — a false-allow in the authorization path gets a release to itself.
Scope decision (settled): validate only what the API model states
Refuse the cases AWS's API reference makes explicit:
Ebs.VolumeSizenorEbs.SnapshotId;DeviceNameacross two mappings;VirtualNamecombined withEbs.*members on one mapping;Throughputon a non-gp3volume type;Iopson a type that takes none.Do not encode the per-type numeric size/IOPS ranges from the user-guide table. Those ranges drift as AWS raises limits, and a stale range refuses a request real EC2 accepts — a false deny baked into the emulator, which is the failure mode substrate can least afford. That removes "a size outside the type's documented range, and an IOPS value outside it" from the list above.
Message provenance
InvalidBlockDeviceMappingappears in the "Client error codes for specific actions" table, with the message text described only as "The returned message indicates the incorrect value". AWS documents no wording, so substrate's per-case messages are its own and the code comment must say so, per the house provenance rule.EbsBlockDevicegives "You must specify either a snapshot ID or a volume size" for the size-vs-snapshot case, and "This parameter is valid only forgp3volumes" forThroughput.DeviceName, nor forVirtualNamebesideEbs.*. Both refusals rest on substrate's own reading of the model and should be labelled that way in the comment rather than presented as observed behaviour.Answering the fourth acceptance criterion
CreateLaunchTemplateanswers an invalid mapping with aValidationWarningon a successful response, not a client error. SoCreateLaunchTemplateshould not refuse; refusal happens atRunInstancestime only. That resolves the "check rather than assume" half of the criterion.Validate-then-write
runInstancesWithTagsis already validate-then-write in shape — every&AWSErrorreturn precedes the firststate.Put. Two things break it:ensureDefaultVPC(emulator/ec2_plugin.go:502-521) mutates state before the security-group validation at:542, so a refused launch can already leave a default VPC behind.Count> 1 launch that fails partway leaves instance 1 written.Both need addressing for the "a refused launch leaves no partial state" criterion to hold as written.
One more note
EC2Snapshot.VolumeSizeis hardcoded to8at its single producer (createImage,emulator/ec2_plugin.go:3225). So a size-vs-snapshot comparison currently exercises a constant — the test can pass without the comparison being correct. Either the producer records a real size first, or the test seeds the snapshot record directly and says why.feat(ec2): refuse a block device mapping real EC2 rejects (#671) (#680)
fix(iam): a boundary an SDK can read, and a count something wrote (#852…
fix(ec2): one offset paginator, and two describes that publish a curs…
fix(ec2): paginate the five remaining describes that publish a cursor (…
feat(ec2): three describes with no published MaxResults range page (#…
feat(ec2): five describes with a published 5-floor range page (#1024) (…
fix(#1062): nine 200s for an absent required member become refusals (#…
fix(#1066): thirty-five body-parse refusals stop leaking the decoder'…
fix(#1090): every ECR refusal is a 400, and three of them can now fire (
fix(#1090): the three ECR listings page, in the three shapes their pa…
fix(#1089): three updates replace where their own page says so, and t…
fix(#1077): propagation writes past a resource's tag quota, and that …
fix(#1086): SNS's three listings refuse a token they never issued (#1220
fix(#1086): Athena's two listings refuse a token they never issued (#…
fix(#1086): CloudWatch Logs' four listings refuse a token they never …
fix(#1125): a subscription attribute that is stored, and read back (#…
fix(#1223): both tokens GetLogEvents publishes, and the rule stated i…
fix(#856): the identity, keys and certificates family of draw sites (#…
fix(#856): the analytics family of draw sites (#1288)
fix(#856): the CI/CD family of draw sites (#1289)
fix(#856): the long tail of draw sites — SSM, RAM, Backup and Bedrock (…