From 3baf4f48496d31d67f5786d2fa5d8fee15bd8e1d Mon Sep 17 00:00:00 2001 From: lex00 <121451605+lex00@users.noreply.github.com> Date: Sat, 1 Aug 2026 15:20:13 -0600 Subject: [PATCH] feat(ec2): return an empty set for DescribeVpnGateways (#1975) * feat(ec2): return an empty set for DescribeVpnGateways There is no VPN gateway model, so an empty vpnGatewaySet is AWS-accurate for an account without VPN gateways. Unblocks the CDK CLI's VPC context provider (Vpc.fromLookup), which always issues this describe and aborts the whole lookup on UnsupportedOperation. Fixes #1974 * test(ec2): assert the vpn gateway set is empty, not merely present The substring check passed for any response containing handleDeleteInternetGateway(params, region); case "AttachInternetGateway" -> handleAttachInternetGateway(params, region); case "DetachInternetGateway" -> handleDetachInternetGateway(params, region); + // VPN Gateways. There is no VPN gateway model; an empty set is + // AWS-accurate for an account without VPN gateways and unblocks the + // CDK VPC context provider, which always issues this describe. + case "DescribeVpnGateways" -> handleDescribeVpnGateways(); + // Route Tables case "CreateRouteTable" -> handleCreateRouteTable(params, region); case "DescribeRouteTables" -> handleDescribeRouteTables(params, region); @@ -1435,6 +1440,16 @@ public class Ec2QueryHandler { return xmlResponse(xml.build()); } + private Response handleDescribeVpnGateways() { + XmlBuilder xml = new XmlBuilder() + .start("DescribeVpnGatewaysResponse", AwsNamespaces.EC2) + .elem("requestId", UUID.randomUUID().toString()) + .start("vpnGatewaySet") + .end("vpnGatewaySet") + .end("DescribeVpnGatewaysResponse"); + return xmlResponse(xml.build()); + } + private Response handleDescribeRouteTables(MultivaluedMap p, String region) { List ids = getList(p, "RouteTableId"); Map> filters = getFilters(p); diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java index d023bfa316..ee22c5a21a 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java @@ -1,6 +1,8 @@ package io.github.hectorvent.floci.services.ec2; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.emptyOrNullString; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.everyItem; @@ -1304,6 +1306,20 @@ class Ec2IntegrationTest { .statusCode(200); } + @Test + @Order(52) + void describeVpnGatewaysReturnsEmptySet() { + given() + .formParam("Action", "DescribeVpnGateways") + .header("Authorization", AUTH_HEADER) + .when() + .post("/") + .then() + .statusCode(200) + .body("DescribeVpnGatewaysResponse.vpnGatewaySet.item.size()", equalTo(0)) + .body(not(containsString("UnsupportedOperation"))); + } + @Test @Order(52) void describeInternetGateways() {