fix(ec2): ignore NoDevice block device mappings at launch (#5739)

A RunInstances or CreateFleet BlockDeviceMapping with NoDevice set removes
its device regardless of the other values it carries. The root volume type
resolution and the VolumeType validation read Ebs on such entries, so a
request that removed a template's gp3 root still got gp3, and a removed
mapping naming an unknown VolumeType failed with InvalidParameterValue.
Drop NoDevice entries before both, on the request-only and template-merged
paths alike.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-15 16:39:12 -04:00
1 parent 0eee5ee28d
commit 5544a119d3
3 files changed
+41 -7

No files matched your search

@@ -3359,12 +3359,13 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
validateArchitectureCompatibility(region, imageId, effectiveInstanceType);
int count = Math.min(maxCount, Math.max(minCount, 1));
String architecture = architectureFor(region, imageId, effectiveInstanceType);
if (blockDeviceMappings != null) {
blockDeviceMappings.stream()
.filter(m -> m.getEbs() != null && m.getEbs().getVolumeType() != null)
.forEach(m -> requireValidVolumeType(m.getEbs().getVolumeType()));
}
String rootVolumeType = rootVolumeTypeFor(findImageForCapture(region, imageId), blockDeviceMappings);
// An entry with NoDevice set removes its device whatever else it names, as on AWS.
List<LaunchTemplateData.BlockDeviceMapping> mappedDevices = blockDeviceMappings == null ? List.of()
: blockDeviceMappings.stream().filter(m -> m.getNoDevice() == null).toList();
mappedDevices.stream()
.filter(m -> m.getEbs() != null && m.getEbs().getVolumeType() != null)
.forEach(m -> requireValidVolumeType(m.getEbs().getVolumeType()));
String rootVolumeType = rootVolumeTypeFor(findImageForCapture(region, imageId), mappedDevices);
List<Instance> launched = new ArrayList<>();
// Resolving the AMI, building the instances that depend on it and publishing them is one
// step. A DeregisterImage releases the captured layer only when no live instance resolves