fix(ec2): return real AWS error for unknown availability zone name (#5529)

DescribeAvailabilityZones now answers unknown ZoneNames with the same
message AllocateHosts uses, 'Invalid availability zone: [<name>]',
matching real AWS responses quoted in eksctl-io/eksctl#8174, instead of
'The zone name ... is not valid for this region.'

The integration test now asserts the exact message. ZoneId behavior is
unchanged.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
Matheus Oliveira authored and GitHub committed 2026-10-12 18:37:37 -04:00
1 parent aff6f0eec4
commit 06f0e06fc1
2 files changed
+3 -2

No files matched your search

@@ -9352,7 +9352,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
}
if (!found) {
throw new AwsException("InvalidParameterValue",
"The zone name '" + requestedName + "' is not valid for this region.", 400);
"Invalid availability zone: [" + requestedName + "]", 400);
}
}
allZones.removeIf(az -> !requestedNames.contains(az.get("zoneName")));
@@ -207,7 +207,8 @@ class Ec2IntegrationTest {
.post("/")
.then()
.statusCode(400)
.body("Response.Errors.Error.Code", equalTo("InvalidParameterValue"));
.body("Response.Errors.Error.Code", equalTo("InvalidParameterValue"))
.body("Response.Errors.Error.Message", equalTo("Invalid availability zone: [us-east-1aa]"));
}
@Test