fix(ec2): return AWS-parity MissingParameter for CreateSubnet without VpcId (#2094)

* fix(ec2): return AWS-parity MissingParameter for CreateSubnet without VpcId

CreateSubnet passed a null VpcId straight into the VPC lookup, producing
"The vpc ID 'null' does not exist" instead of the MissingParameter error
real EC2 returns for a required-but-absent parameter (#2089).

* test(ec2): cover CreateSubnet missing VpcId at unit level

Asserts createSubnet(null vpcId) throws MissingParameter rather than
InvalidVpcID.NotFound with a literal "null" in the message.

* test(ec2): cover CreateSubnet missing VpcId over the wire

Exercises the Query API handler directly (no VpcId form param) to pin
the AWS-parity MissingParameter response end-to-end.

* test(ec2): cover blank VpcId for CreateSubnet at unit level

Greptile flagged that isBlank() also covers empty/whitespace VpcId,
a branch the original tests didn't exercise directly.

* test(ec2): cover blank VpcId for CreateSubnet over the wire

Companion to the unit-level blank VpcId case, exercised through the
Query API handler.
This commit is contained in:
Feyikemi Ogunsanya authored and GitHub committed 2026-08-04 21:48:02 -05:00
1 parent 6a214e84d6
commit 88408d8574
3 files changed
+64

No files matched your search

@@ -1302,6 +1302,9 @@ public class Ec2Service implements ContainerTeardown {
// ─── Subnets ───────────────────────────────────────────────────────────────
public Subnet createSubnet(String region, String vpcId, String cidrBlock, String availabilityZone) {
if (vpcId == null || vpcId.isBlank()) {
throw new AwsException("MissingParameter", "The request must contain the parameter VpcId", 400);
}
ensureDefaultResources(region);
getRequiredVpc(region, vpcId);