feat(ec2): auto-create default security group and main route table on CreateVpc (closes #1091) (#1177)

* feat(ec2): implement default security group and main route table creation for VPC

* fix(ec2): update route table association check to use boolean value

* test(ec2): update security group test to validate group name and VPC ID

* fix(ec2): update security group description in Ec2Service and corresponding tests

* test(ec2): fix integration test failures

* fix(ec2): fix integration test error

* feat(ec2): update description

* fix(ec2): fix SG id to use 17 character hex code
This commit is contained in:
Prakhar Kapoor authored and GitHub committed 2026-06-09 00:34:51 -05:00
1 parent 40c1c4339d
commit 3065774e80
2 files changed
+79 -24

No files matched your search

@@ -1,6 +1,7 @@
package io.github.hectorvent.floci.services.ec2;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.not;
@@ -91,6 +92,8 @@ class Ec2IntegrationTest {
.statusCode(200)
.contentType("application/xml")
.body("DescribeSecurityGroupsResponse.securityGroupInfo.item[0].groupName", equalTo("default"))
.body("DescribeSecurityGroupsResponse.securityGroupInfo.item[0].groupDescription",
equalTo("default VPC security group"))
.body("DescribeSecurityGroupsResponse.securityGroupInfo.item[0].vpcId", equalTo("vpc-default"));
}
@@ -243,6 +246,43 @@ class Ec2IntegrationTest {
@Test
@Order(14)
void describeCreatedVpcDefaultSecurityGroup() {
given()
.formParam("Action", "DescribeSecurityGroups")
.formParam("Filter.1.Name", "vpc-id")
.formParam("Filter.1.Value.1", vpcId)
.formParam("Filter.2.Name", "group-name")
.formParam("Filter.2.Value.1", "default")
.header("Authorization", AUTH_HEADER)
.when()
.post("/")
.then()
.statusCode(200)
.body("DescribeSecurityGroupsResponse.securityGroupInfo.item.groupName", equalTo("default"))
.body("DescribeSecurityGroupsResponse.securityGroupInfo.item.vpcId", equalTo(vpcId));
}
@Test
@Order(15)
void describeCreatedVpcMainRouteTable() {
given()
.formParam("Action", "DescribeRouteTables")
.formParam("Filter.1.Name", "vpc-id")
.formParam("Filter.1.Value.1", vpcId)
.formParam("Filter.2.Name", "association.main")
.formParam("Filter.2.Value.1", "true")
.header("Authorization", AUTH_HEADER)
.when()
.post("/")
.then()
.statusCode(200)
.body("DescribeRouteTablesResponse.routeTableSet.item.vpcId", equalTo(vpcId))
.body("DescribeRouteTablesResponse.routeTableSet.item.associationSet.item.main",
anyOf(equalTo(true), equalTo("true")));
}
@Test
@Order(16)
void describeVpcEndpointServices() {
given()
.formParam("Action", "DescribeVpcEndpointServices")