mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(ec2): answer DescribeTransitGatewayConnects with an empty list (#3274)
* fix(ec2): answer DescribeTransitGatewayConnects with an empty list LZA's tgw-associations-and-propagations module calls this unconditionally alongside DescribeTransitGatewayVpcAttachments. floci does not yet support creating Connect attachments, so the action was entirely unhandled and the module failed with "Operation DescribeTransitGatewayConnects is not supported", found while running LZA phase2 against parent 1176. Since floci has no Connect attachments to return, an empty list is the wire-faithful answer for every account. Requested attachment ids still validate against the shared tgw-attach- id namespace: malformed ids reuse the existing InvalidTransitGatewayAttachmentID.Malformed check, well-formed but unknown ids get InvalidTransitGatewayConnectID.NotFound. * test(ec2): cover DescribeTransitGatewayConnects over the Query protocol and make the service hook void The service method only validates the request; the handler always renders an empty transitGatewayConnectSet, so returning a List of VPC attachments suggested a resource type it never produces. It is void now. Two integration tests drive the action through the EC2 Query dispatch and pin the response wire shape (EC2 namespace, requestId, empty transitGatewayConnectSet) and the Malformed / Connect NotFound error codes.
This commit is contained in:
1 parent
c57b8ff5f6
commit
f30ba77ac0
5 files changed
+96
No files matched your search
@@ -385,6 +385,7 @@ and `DescribeTransitGateways` include it.
|
||||
| CreateTransitGatewayVpcAttachment | Attaches a VPC to a transit gateway through one subnet per availability zone. |
|
||||
| DescribeTransitGatewayVpcAttachments | Lists or returns VPC attachments with their subnets and options. |
|
||||
| DescribeTransitGatewayAttachments | Returns the same attachments in the resource-agnostic shape, including the route table association. |
|
||||
| DescribeTransitGatewayConnects | Always returns an empty list, since Connect attachments cannot be created yet; requested ids are still validated. |
|
||||
| ModifyTransitGatewayVpcAttachment | Adds or removes attachment subnets and updates its options. |
|
||||
| DeleteTransitGatewayVpcAttachment | Deletes a VPC attachment. |
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ public class Ec2QueryHandler {
|
||||
handleDescribeTransitGatewayVpcAttachments(params, region);
|
||||
case "DescribeTransitGatewayAttachments" ->
|
||||
handleDescribeTransitGatewayAttachments(params, region);
|
||||
case "DescribeTransitGatewayConnects" -> handleDescribeTransitGatewayConnects(params, region);
|
||||
case "ModifyTransitGatewayVpcAttachment" ->
|
||||
handleModifyTransitGatewayVpcAttachment(params, region);
|
||||
case "DeleteTransitGatewayVpcAttachment" ->
|
||||
@@ -2181,6 +2182,18 @@ public class Ec2QueryHandler {
|
||||
return xmlResponse(xml.build());
|
||||
}
|
||||
|
||||
/** floci does not yet support creating Connect attachments, so this is always an empty list. */
|
||||
private Response handleDescribeTransitGatewayConnects(MultivaluedMap<String, String> p, String region) {
|
||||
service.describeTransitGatewayConnects(region, getList(p, "TransitGatewayAttachmentIds"), getFilters(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeTransitGatewayConnectsResponse", AwsNamespaces.EC2)
|
||||
.elem("requestId", UUID.randomUUID().toString())
|
||||
.start("transitGatewayConnectSet")
|
||||
.end("transitGatewayConnectSet")
|
||||
.end("DescribeTransitGatewayConnectsResponse");
|
||||
return xmlResponse(xml.build());
|
||||
}
|
||||
|
||||
private Response handleModifyTransitGatewayVpcAttachment(MultivaluedMap<String, String> p, String region) {
|
||||
TransitGatewayVpcAttachment attachment = service.modifyTransitGatewayVpcAttachment(
|
||||
region,
|
||||
|
||||
@@ -1610,6 +1610,22 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* floci does not yet support creating Connect attachments, so the Query handler always
|
||||
* answers with an empty set, the same thing a real account with none would get back; this
|
||||
* only validates the request (a dedicated Connect model can replace it later). Requested ids still
|
||||
* validate the same way {@link #describeTransitGatewayVpcAttachments} validates VPC attachment
|
||||
* ids, since Connect attachments share the same {@code tgw-attach-} id namespace.
|
||||
*/
|
||||
public void describeTransitGatewayConnects(
|
||||
String region, List<String> attachmentIds, Map<String, List<String>> filters) {
|
||||
attachmentIds.forEach(Ec2Service::requireWellFormedAttachmentId);
|
||||
if (!attachmentIds.isEmpty()) {
|
||||
throw new AwsException("InvalidTransitGatewayConnectID.NotFound",
|
||||
"Transit Gateway Connect " + attachmentIds.get(0) + " was deleted or does not exist.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
public TransitGatewayVpcAttachment modifyTransitGatewayVpcAttachment(
|
||||
String region, String attachmentId, List<String> addSubnetIds, List<String> removeSubnetIds,
|
||||
TransitGatewayVpcAttachmentOptions changes) {
|
||||
|
||||
@@ -50,6 +50,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
@@ -2598,6 +2599,32 @@ class Ec2ServiceTest {
|
||||
"a well-formed id that does not exist is a different failure");
|
||||
}
|
||||
|
||||
/**
|
||||
* floci does not yet support creating Connect attachments, so LZA's tgw-associations-and-
|
||||
* propagations module, which describes them unconditionally alongside VPC attachments, needs
|
||||
* this to at least answer with an empty account-wide list rather than an unrecognized-action
|
||||
* error (LZA fidelity gap: AWSAccelerator-ToolkitProject build 29 failed with "Operation
|
||||
* DescribeTransitGatewayConnects is not supported").
|
||||
*/
|
||||
@Test
|
||||
void describeTransitGatewayConnectsReturnsEmptyWhenNoneExist() {
|
||||
Ec2Service service = prefixListService();
|
||||
|
||||
assertDoesNotThrow(() -> service.describeTransitGatewayConnects("us-east-1", List.of(), Map.of()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeTransitGatewayConnectsRejectsAMalformedOrUnknownId() {
|
||||
Ec2Service service = prefixListService();
|
||||
|
||||
assertEquals("InvalidTransitGatewayAttachmentID.Malformed", assertThrows(AwsException.class,
|
||||
() -> service.describeTransitGatewayConnects("us-east-1", List.of("tgw-connect-nope"), Map.of()))
|
||||
.getErrorCode());
|
||||
assertEquals("InvalidTransitGatewayConnectID.NotFound", assertThrows(AwsException.class,
|
||||
() -> service.describeTransitGatewayConnects("us-east-1",
|
||||
List.of("tgw-attach-0123456789abcdef0"), Map.of())).getErrorCode());
|
||||
}
|
||||
|
||||
/** The gateway's owner is its own field, sourced from the gateway rather than from the VPC. */
|
||||
@Test
|
||||
void anAttachmentRecordsBothOwnersSeparately() {
|
||||
|
||||
+39
@@ -205,4 +205,43 @@ class Ec2TransitGatewayVpcAttachmentIntegrationTest {
|
||||
.then().statusCode(200)
|
||||
.body("DeleteTransitGatewayResponse.transitGateway.state", equalTo("deleted"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect attachments cannot be created yet, so the describe answers with the AWS-shaped
|
||||
* empty collection: the EC2 namespace, a requestId, and an empty transitGatewayConnectSet.
|
||||
*/
|
||||
@Test
|
||||
@Order(7)
|
||||
void describeTransitGatewayConnectsAnswersAnEmptySetOverTheQueryProtocol() {
|
||||
String body = given()
|
||||
.formParam("Action", "DescribeTransitGatewayConnects")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body("DescribeTransitGatewayConnectsResponse.requestId", not(equalTo("")))
|
||||
.extract().asString();
|
||||
|
||||
assertThat(body, containsString("<DescribeTransitGatewayConnectsResponse xmlns=\"http://ec2.amazonaws.com/doc/2016-11-15/\">"));
|
||||
assertThat(body, containsString("<transitGatewayConnectSet></transitGatewayConnectSet>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void describeTransitGatewayConnectsRejectsMalformedAndUnknownIdsOverTheQueryProtocol() {
|
||||
given()
|
||||
.formParam("Action", "DescribeTransitGatewayConnects")
|
||||
.formParam("TransitGatewayAttachmentIds.1", "tgw-connect-nope")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when().post("/")
|
||||
.then().statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidTransitGatewayAttachmentID.Malformed"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "DescribeTransitGatewayConnects")
|
||||
.formParam("TransitGatewayAttachmentIds.1", "tgw-attach-0123456789abcdef0")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when().post("/")
|
||||
.then().statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidTransitGatewayConnectID.NotFound"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user