Repository navigation
Description
Summary
RunInstances' inline BlockDeviceMapping.N.Ebs.* parameters (root/additional volume specs given at launch time, as opposed to a separate CreateVolume call) are parsed nowhere in emulator/ec2_plugin.go's runInstancesWithTags, and never populate the volume: state namespace that DescribeVolumes (added for #256) reads from. So a launch that specifies BlockDeviceMapping.1.Ebs.VolumeSize=60 produces an instance with no discoverable volume at all — DescribeVolumes returns zero results for it, and DescribeInstanceAttribute with blockDeviceMapping is explicitly rejected (grep confirms no such attribute case exists).
Confirmed via source inspection against v0.102.0 (latest):
grep -n "BlockDeviceMapping\." emulator/ec2_plugin.go(excluding tests) shows exactly one read site,BlockDeviceMapping.N.Ebs.SnapshotId, used only for AMI-registration snapshot lookup (~line 3263) — not called fromrunInstancesWithTags.runInstancesWithTags(~line 280) parsesImageId,InstanceType, counts,KeyName, IAM profile,UserData,DisableApiTermination, placement, subnet/SG, network interfaces — noBlockDeviceMapping.*of any kind.describeVolumes(~line 4724) lists only fromp.state.List(ctx, ec2Namespace, "volume:"+account+"/"+region+"/")— the namespaceCreateVolume(EC2: Add EBS volume operations (CreateVolume, DescribeVolumes, AttachVolume, DetachVolume, DeleteVolume, DeleteSnapshot) #256) writes to, and nothing else does.
Also confirmed empirically from a consumer (spawn, spore-host/spawn#544's fix PR): a real launch with a custom root volume size followed immediately by DescribeVolumes against the Substrate emulator (pinned v0.97.0, same gap present) returned zero volumes for the instance.
Impact
Any test asserting "the instance I just launched has a root volume of size X" (the natural way to verify a root-volume-size feature, since AWS represents this on the instance's own block device mapping, not as a separate resource) has no queryable state to assert against — despite RunInstances accepting and silently discarding the parameter.
Expected behavior
RunInstances should parse BlockDeviceMapping.N.{DeviceName,Ebs.VolumeSize,Ebs.VolumeType,Ebs.SnapshotId,Ebs.DeleteOnTermination,Ebs.Encrypted,Ebs.Iops,Ebs.Throughput} (repeated, 1-indexed, same convention as the existing NetworkInterface.N/Filter.N parsing elsewhere in this file) and, for each, create a synthetic volume record in the same volume: namespace CreateVolume uses — in-use, attached to the new instance at the given device name, sized/typed per the request (falling back to an AMI-appropriate default, e.g. 8 GiB gp3, when VolumeSize is omitted — mirroring real EC2's "root volume defaults to the AMI snapshot size" behavior). This makes DescribeVolumes (filtered by attachment.instance-id) the single source of truth for both CreateVolume-provisioned and launch-time-specified volumes, matching how real EC2 unifies the two.
A minimal version — just recording VolumeSize per device and making it visible via DescribeVolumes — would already close the gap that matters most (verifying a requested volume size actually took effect); full parity on every Ebs.* sub-field (IOPS, throughput, encryption) can follow the existing volume-plugin's granularity if that's more work than warranted right now.
Repro
RunInstances ... &BlockDeviceMapping.1.DeviceName=/dev/xvda&BlockDeviceMapping.1.Ebs.VolumeSize=60
# -> instance launches successfully
DescribeVolumes --filters Name=attachment.instance-id,Values=<id>
# -> <volumeSet/> (empty), regardless of VolumeSize requested
Related
- EC2: Add EBS volume operations (CreateVolume, DescribeVolumes, AttachVolume, DetachVolume, DeleteVolume, DeleteSnapshot) #256 (closed) — added the standalone
CreateVolume/DescribeVolumes/AttachVolume/DetachVolume/DeleteVolumelifecycle. This issue is the missing other half: the inline form of volume specification that realRunInstancesalso accepts, which EC2: Add EBS volume operations (CreateVolume, DescribeVolumes, AttachVolume, DetachVolume, DeleteVolume, DeleteSnapshot) #256's fix never touched. - Found while fixing Root volume size is unreachable on the sweep path:
--volume-sizeis dropped andvolume_size:is rejected, so every sweep row is hard-pinned at 20 GiB spore-host/spawn#544 (root EBS volume size unreachable on spawn's parameter-sweep launch path) — the intended Tier 0 regression test wanted to assert the launched instance's actual volume size viaDescribeVolumes, and this gap made that impossible; the spawn-side fix worked around it with a recording reverse-proxy that inspects the rawRunInstanceswire request instead ofDescribeVolumes, which is a heavier-weight substitute than the emulator should require.
Activity
scttfrdmn commentedon Aug 20, 2026
Fixed in #668, shipping in v0.103.0.
Your framing was exactly right, and worth restating because it is why this could not be
fixed by exposing the mapping on the instance: AWS's
EbsInstanceBlockDevice— the shapeDescribeInstancesrenders per device — carriesvolumeId,attachTime,deleteOnTerminationandstatus, and no size.DescribeVolumesis the only APIsurface on which a launch-specified size is observable at all, so the 60 GiB you asked for
was not merely hidden, it was unreachable. A launch now materializes real volumes in the
same store
CreateVolumewrites to.Two decisions in the fix are worth flagging, since neither is what a reader would guess.
Every
RunInstancesnow produces at least one volume. A real instance always has aroot volume whether or not the request mentions one, and substrate's
DescribeImagesalready reported an 8 GiB
/dev/sda1mapping for every AMI it serves — so producing noneleft those two APIs disagreeing about the same instance. A launch declaring no mapping now
gets a synthesized 8 GiB
gp2volume at/dev/sda1.The compatibility cost is real and accepted: a test that listed all volumes and
expected only what it created with
CreateVolumewill now see a root volume per launchedinstance. Filter by
volume-idorattachment.instance-idfor the old answer.Root devices are recognized by name —
/dev/sda1and/dev/xvda, the two spellingsAWS's device-naming reference gives for the HVM root ("Differs by AMI"). That detail
mattered for your repro specifically: a rule recognizing only
/dev/sda1would haveanswered
/dev/xvda+ 60 with two volumes, yours plus a spurious 8 GiB root.DeleteOnTerminationdefaults totruefor data volumes too. Counter-intuitive, andit comes straight from AWS's
preserving-volumes-on-terminationtable, which splits onhow the volume was attached rather than on what it is: a data volume attached at launch
through the console preserves, but through the CLI/API it is deleted. An API
emulator only has the CLI path, so every volume a launch creates defaults to
true, andAttachVolumekeeps the other default,false— deleting a volume you brought woulddestroy something the launch did not make.
TerminateInstancesnow honors that, which is what made the parsing safe to land at all.Without it a volume would report
deleteOnTermination=truewhile sittingin-useon aterminated instance forever — a state real EC2 never reaches, and a new inaccuracy in
place of the old silence.
Also in the fix:
iopsandthroughputnow reach the wire (IOPSwas stored and neverrendered;
throughputhad nowhere to be stored),DescribeVolumesgained theattachment.device,attachment.delete-on-termination,volume-type,size,availability-zoneandsnapshot-idfilters, and a fleet reaches mappings through itslaunch template, which now carries them.
Deliberately out of scope, filed as follow-ups:
blockDeviceMappingonDescribeInstances/DescribeInstanceAttribute(the shape carries no size, so it would notanswer this question), volume tag specifications (a
CreateVolumeparity gap),Ebs.KmsKeyId, andInvalidBlockDeviceMappingvalidation — which needed this state toexist before it could be checked against anything.
fix(ec2): a launch-declared data volume is preserved on termination (#…