fix(ec2): word an AMI and instance type architecture mismatch as RunInstances does (#8403)

RunInstances already refused an AMI whose architecture the instance type
cannot run, as AWS does, but said "The architecture 'x86_64' of the
specified image does not match the architecture supported by instance
type 'm6g.large'.". AWS names the instance type's architecture first:
"The architecture 'arm64' of the specified instance type does not match
the architecture 'x86_64' of the specified AMI."
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-14 22:33:53 -04:00
1 parent b4fbe99123
commit 246d82ec57
3 files changed
+32 -3

No files matched your search

@@ -3559,6 +3559,25 @@ class Ec2ServiceTest {
assertEquals(reservation.getOwnerId(), reservation.getInstances().getFirst().getOwnerId());
}
@Test
void runInstancesRefusesAnImageWhoseArchitectureTheInstanceTypeCannotRun() {
Ec2Service service = new Ec2Service(mockConfig(true), mock(Ec2ContainerManager.class),
mock(Ec2PortForwardManager.class),
mock(AmiImageResolver.class), new Ec2ImageCatalog(), new Ec2InstanceTypeCatalog(),
new InMemoryStorageFactory());
AwsException graviton = assertThrows(AwsException.class, () -> service.runInstances("us-east-1",
"ami-ubuntu2404-amd64", "m6g.large", 1, 1, null, List.of(), null, null, List.of(), null, null));
AwsException intel = assertThrows(AwsException.class, () -> service.runInstances("us-east-1",
"ami-ubuntu2404-arm64", "t3.micro", 1, 1, null, List.of(), null, null, List.of(), null, null));
assertEquals("InvalidParameterValue", graviton.getErrorCode());
assertEquals("The architecture 'arm64' of the specified instance type does not match the architecture "
+ "'x86_64' of the specified AMI.", graviton.getMessage());
assertEquals("The architecture 'x86_64' of the specified instance type does not match the architecture "
+ "'arm64' of the specified AMI.", intel.getMessage());
}
@Test
void runInstancesKeepsX8664FallbackForUnknownImageAndType() {
Ec2Service service = new Ec2Service(mockConfig(true), mock(Ec2ContainerManager.class),