fix(ec2): make default network resource IDs region-unique and AWS-format (#7738)

This commit is contained in:
Matheus Oliveira authored and GitHub committed 2026-11-16 09:10:33 -04:00
1 parent 651ac1cbe7
commit 1dadaee351
29 files changed
+315 -131

No files matched your search

@@ -1,5 +1,6 @@
package io.floci.aws.services.cloudformation;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.BeforeAll;
@@ -65,7 +66,7 @@ class CloudFormationEcsDeleteAfterRestoreIntegrationTest {
// in-memory RUNNING with no container behind it.
ecs("RunTask", "{\"cluster\":\"" + cluster + "\",\"taskDefinition\":\"" + family + "\",\"count\":1,"
+ "\"networkConfiguration\":{\"awsvpcConfiguration\":"
+ "{\"subnets\":[\"subnet-default-us-east-1-a\"]}}}");
+ "{\"subnets\":[\"" + Ec2Service.defaultSubnetId("us-east-1", "a") + "\"]}}}");
deleteStack(stack);
@@ -1,5 +1,6 @@
package io.floci.aws.services.dms;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
@@ -29,8 +30,8 @@ class DmsIntegrationTest {
private static final String ACCOUNT_ID = "723679240095";
private static final String AUTH_HEADER =
"AWS4-HMAC-SHA256 Credential=" + ACCOUNT_ID + "/20260101/us-east-1/dms/aws4_request";
private static final String SUBNET_A = "subnet-default-us-east-1-a";
private static final String SUBNET_B = "subnet-default-us-east-1-b";
private static final String SUBNET_A = Ec2Service.defaultSubnetId("us-east-1", "a");
private static final String SUBNET_B = Ec2Service.defaultSubnetId("us-east-1", "b");
@BeforeAll
static void configureRestAssured() {
@@ -59,7 +60,7 @@ class DmsIntegrationTest {
.body("ReplicationSubnetGroups", hasSize(1))
.body("ReplicationSubnetGroups[0].ReplicationSubnetGroupDescription",
equalTo("terraform managed"))
.body("ReplicationSubnetGroups[0].VpcId", equalTo("vpc-default-us-east-1"))
.body("ReplicationSubnetGroups[0].VpcId", equalTo(Ec2Service.defaultVpcId("us-east-1")))
.body("ReplicationSubnetGroups[0].SubnetGroupStatus", equalTo("Complete"))
.body("ReplicationSubnetGroups[0].Subnets.SubnetIdentifier", contains(SUBNET_A, SUBNET_B))
.body("ReplicationSubnetGroups[0].Subnets.find { it.SubnetIdentifier == '"
@@ -155,7 +156,8 @@ class DmsIntegrationTest {
dms("CreateReplicationSubnetGroup", region)
.body("{\"ReplicationSubnetGroupIdentifier\":\"tf-default-probe\","
+ "\"ReplicationSubnetGroupDescription\":\"terraform managed\","
+ "\"SubnetIds\":[\"subnet-default-ap-southeast-2-a\",\"subnet-default-ap-southeast-2-b\"]}")
+ "\"SubnetIds\":[\"" + Ec2Service.defaultSubnetId(region, "a") + "\",\""
+ Ec2Service.defaultSubnetId(region, "b") + "\"]}")
.when()
.post("/")
.then()
@@ -202,7 +204,7 @@ class DmsIntegrationTest {
.statusCode(200)
.body("ReplicationSubnetGroups", hasSize(1))
.body("ReplicationSubnetGroups[0].ReplicationSubnetGroupIdentifier", equalTo("default"))
.body("ReplicationSubnetGroups[0].VpcId", equalTo("vpc-default-ap-southeast-2"));
.body("ReplicationSubnetGroups[0].VpcId", equalTo(Ec2Service.defaultVpcId("ap-southeast-2")));
}
/**
@@ -230,7 +232,7 @@ class DmsIntegrationTest {
.then()
.statusCode(200)
.body("ReplicationSubnetGroups", hasSize(1))
.body("ReplicationSubnetGroups[0].VpcId", equalTo("vpc-default-ca-central-1"));
.body("ReplicationSubnetGroups[0].VpcId", equalTo(Ec2Service.defaultVpcId("ca-central-1")));
}
@Test
@@ -1,5 +1,6 @@
package io.floci.aws.services.dms;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.ValidatableResponse;
@@ -31,8 +32,8 @@ class DmsLifecycleIntegrationTest {
private static final String ACCOUNT_ID = "723679240095";
private static final String AUTH_HEADER =
"AWS4-HMAC-SHA256 Credential=" + ACCOUNT_ID + "/20260101/us-east-1/dms/aws4_request";
private static final String SUBNET_A = "subnet-default-us-east-1-a";
private static final String SUBNET_B = "subnet-default-us-east-1-b";
private static final String SUBNET_A = Ec2Service.defaultSubnetId("us-east-1", "a");
private static final String SUBNET_B = Ec2Service.defaultSubnetId("us-east-1", "b");
@BeforeAll
static void configureRestAssured() {
@@ -180,7 +181,7 @@ class DmsLifecycleIntegrationTest {
.body("ReplicationInstances[0].VpcSecurityGroups[0].VpcSecurityGroupId", equalTo("sg-1"))
.body("ReplicationInstances[0].ReplicationSubnetGroup.ReplicationSubnetGroupIdentifier",
equalTo("lc-rep-subnets"))
.body("ReplicationInstances[0].ReplicationSubnetGroup.VpcId", equalTo("vpc-default-us-east-1"))
.body("ReplicationInstances[0].ReplicationSubnetGroup.VpcId", equalTo(Ec2Service.defaultVpcId("us-east-1")))
.body("ReplicationInstances[0].EngineVersion", notNullValue());
dms("DeleteReplicationSubnetGroup")
@@ -231,7 +232,7 @@ class DmsLifecycleIntegrationTest {
describeInstance("lc-rep-default")
.body("ReplicationInstances[0].ReplicationSubnetGroup.ReplicationSubnetGroupIdentifier",
equalTo("default"))
.body("ReplicationInstances[0].ReplicationSubnetGroup.VpcId", equalTo("vpc-default-us-east-1"))
.body("ReplicationInstances[0].ReplicationSubnetGroup.VpcId", equalTo(Ec2Service.defaultVpcId("us-east-1")))
.body("ReplicationInstances[0].ReplicationSubnetGroup.SubnetGroupStatus", equalTo("Complete"))
.body("ReplicationInstances[0].ReplicationSubnetGroup.Subnets.SubnetIdentifier",
hasItems(SUBNET_A, SUBNET_B));
@@ -83,8 +83,10 @@ class DocDbClusterSnapshotServiceTest {
key.setEnabled(true);
key.setKeyState("Enabled");
doReturn(key).when(kmsService).describeKey(KEY_ARN, "us-east-1");
Ec2Service ec2Service = mock(Ec2Service.class);
when(ec2Service.resolveDefaultSecurityGroupId(anyString())).thenAnswer(inv -> Ec2Service.defaultSecurityGroupId(inv.getArgument(0)));
docDbService = new DocDbService(config, new RegionResolver("us-east-1", "000000000000"), containerManager,
storageFactory, mock(RdsService.class), mock(Ec2Service.class), kmsService);
storageFactory, mock(RdsService.class), ec2Service, kmsService);
}
@Test
@@ -68,6 +68,7 @@ class DocDbServiceTest {
RegionResolver regionResolver = new RegionResolver("us-east-1", "000000000000");
rdsService = Mockito.mock(RdsService.class);
ec2Service = Mockito.mock(Ec2Service.class);
when(ec2Service.resolveDefaultSecurityGroupId(anyString())).thenAnswer(inv -> Ec2Service.defaultSecurityGroupId(inv.getArgument(0)));
kmsService = Mockito.mock(KmsService.class);
when(kmsService.describeKey(any(), any())).thenThrow(new AwsException("NotFoundException", "Key not found", 404));
when(rdsService.isManagedClusterParameterGroup(any())).thenAnswer(inv ->
@@ -132,7 +132,7 @@ class Ec2CreateFleetIntegrationTest {
.formParam("LaunchTemplateConfig.1.LaunchTemplateSpecification.Version", "1")
.formParam("LaunchTemplateConfig.1.Overrides.1.InstanceType", "t3.micro")
.formParam("LaunchTemplateConfig.1.Overrides.1.ImageId", CONTRACT_IMAGE_ID)
.formParam("LaunchTemplateConfig.1.Overrides.1.SubnetId", "subnet-default-us-east-1-a")
.formParam("LaunchTemplateConfig.1.Overrides.1.SubnetId", Ec2Service.defaultSubnetId("us-east-1", "a"))
.formParam("LaunchTemplateConfig.1.Overrides.1.AvailabilityZone", "us-east-1b")
.formParam("TargetCapacitySpecification.TotalTargetCapacity", "1")
.formParam("TargetCapacitySpecification.DefaultTargetCapacityType", "on-demand")
@@ -157,7 +157,7 @@ class Ec2CreateFleetIntegrationTest {
.formParam("LaunchTemplateConfig.1.LaunchTemplateSpecification.Version", "1")
.formParam("LaunchTemplateConfig.1.Overrides.1.InstanceType", "t3.micro")
.formParam("LaunchTemplateConfig.1.Overrides.1.ImageId", CONTRACT_IMAGE_ID)
.formParam("LaunchTemplateConfig.1.Overrides.1.SubnetId", "subnet-default-us-east-1-b")
.formParam("LaunchTemplateConfig.1.Overrides.1.SubnetId", Ec2Service.defaultSubnetId("us-east-1", "b"))
.formParam("TargetCapacitySpecification.TotalTargetCapacity", "1")
.formParam("TargetCapacitySpecification.DefaultTargetCapacityType", "on-demand")
.header("Authorization", AUTH_HEADER)
@@ -167,9 +167,9 @@ class Ec2CreateFleetIntegrationTest {
.statusCode(200)
.body("CreateFleetResponse.fleetInstanceSet.item.availabilityZone", equalTo("us-east-1b"))
.body("CreateFleetResponse.fleetInstanceSet.item.subnetId",
equalTo("subnet-default-us-east-1-b"))
equalTo(Ec2Service.defaultSubnetId("us-east-1", "b")))
.body("CreateFleetResponse.fleetInstanceSet.item.launchTemplateAndOverrides.overrides.subnetId",
equalTo("subnet-default-us-east-1-b"))
equalTo(Ec2Service.defaultSubnetId("us-east-1", "b")))
.body("CreateFleetResponse.fleetInstanceSet.item.launchTemplateAndOverrides.overrides.availabilityZone",
equalTo("us-east-1b"));
}
@@ -660,7 +660,7 @@ class Ec2QueryHandlerTest {
void aSecurityGroupDryRunWithoutAVpcIdNeedsTheDefaultVpcToExist() {
Ec2Service service = mock(Ec2Service.class);
when(service.requireSecurityGroupVpc("us-east-1", null)).thenThrow(new AwsException(
"InvalidVpcID.NotFound", "The vpc ID 'vpc-default-us-east-1' does not exist", 400));
"InvalidVpcID.NotFound", "The vpc ID '" + Ec2Service.defaultVpcId("us-east-1") + "' does not exist", 400));
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
params.putSingle("GroupName", "test");
params.putSingle("GroupDescription", "test");
@@ -20,7 +20,7 @@ import io.floci.aws.services.ec2.model.GroupIdentifier;
import io.floci.aws.services.ec2.model.Image;
import io.floci.aws.services.ec2.model.Instance;
import io.floci.aws.services.ec2.model.InstanceState;
import io.floci.aws.services.ec2.model.IpPermission;
import io.floci.aws.services.ec2.model.InternetGateway;
import io.floci.aws.services.ec2.model.IpPermission;
import io.floci.aws.services.ec2.model.IpRange;
import io.floci.aws.services.ec2.model.Ipv6Range;
@@ -30,6 +30,7 @@ import io.floci.aws.services.ec2.model.LaunchTemplateData;
import io.floci.aws.services.ec2.model.ManagedPrefixList;
import io.floci.aws.services.ec2.model.NatGateway;
import io.floci.aws.services.ec2.model.NatGatewayAddress;
import io.floci.aws.services.ec2.model.NetworkAcl;
import io.floci.aws.services.ec2.model.NetworkInterface;
import io.floci.aws.services.ec2.model.NetworkInterfaceAssociation;
import io.floci.aws.services.ec2.model.NetworkInterfaceListResult;
@@ -39,9 +40,9 @@ import io.floci.aws.services.ec2.model.PrefixList;
import io.floci.aws.services.ec2.model.PrefixListEntry;
import io.floci.aws.services.ec2.model.PrefixListId;
import io.floci.aws.services.ec2.model.Reservation;
import io.floci.aws.services.ec2.model.RouteTable;
import io.floci.aws.services.ec2.model.SecurityGroup;
import io.floci.aws.services.ec2.model.SecurityGroupRule;
import io.floci.aws.services.ec2.model.SecurityGroupRule;
import io.floci.aws.services.ec2.model.Snapshot;
import io.floci.aws.services.ec2.model.Subnet;
import io.floci.aws.services.ec2.model.Tag;
@@ -4373,6 +4374,84 @@ class Ec2ServiceTest {
assertEquals(Ec2Service.defaultSecurityGroupId("eu-west-1"), euWestSg.getGroupId());
}
@Test
void defaultNetworkResourceIdsHaveEc2ShapeAndAreRegionUniqueAndStable() {
Ec2Service service = new Ec2Service(mockConfig(true), mock(Ec2ContainerManager.class),
mock(Ec2PortForwardManager.class),
mock(AmiImageResolver.class), mock(Ec2ImageCatalog.class), new Ec2InstanceTypeCatalog(),
new InMemoryStorageFactory());
for (String region : List.of("us-east-1", "eu-west-1")) {
InternetGateway igw = service.describeInternetGateways(region, List.of(), Map.of()).getFirst();
assertTrue(igw.getInternetGatewayId().startsWith("igw-"));
assertTrue(isHex17(igw.getInternetGatewayId().substring(4)));
List<RouteTable> rts = service.describeRouteTables(region, List.of(), Map.of());
RouteTable mainRt = rts.isEmpty() ? null : rts.getFirst();
assertTrue(mainRt.getRouteTableId().startsWith("rtb-"));
assertTrue(isHex17(mainRt.getRouteTableId().substring(4)));
assertTrue(mainRt.getAssociations().stream().allMatch(a ->
a.getRouteTableAssociationId().startsWith("rtbassoc-")
&& isHex17(a.getRouteTableAssociationId().substring(9))));
List<NetworkAcl> acls = service.describeNetworkAcls(region, List.of(), Map.of());
NetworkAcl defaultAcl = acls.stream().filter(NetworkAcl::isDefault).findFirst().orElse(acls.getFirst());
assertTrue(defaultAcl.getNetworkAclId().startsWith("acl-"));
assertTrue(isHex17(defaultAcl.getNetworkAclId().substring(4)));
assertTrue(defaultAcl.getAssociations().stream().allMatch(a ->
a.getNetworkAclAssociationId().startsWith("aclassoc-")
&& isHex17(a.getNetworkAclAssociationId().substring(9))));
Vpc vpc = service.describeVpcs(region, List.of(), Map.of()).getFirst();
assertTrue(vpc.getCidrBlockAssociationSet().stream().allMatch(c ->
c.getAssociationId().startsWith("vpc-cidr-assoc-")
&& isHex17(c.getAssociationId().substring("vpc-cidr-assoc-".length()))));
}
// uniqueness across regions, for every default resource type
List<String> usEastIds = defaultResourceIds(service, "us-east-1");
List<String> euWestIds = defaultResourceIds(service, "eu-west-1");
assertTrue(usEastIds.stream().noneMatch(euWestIds::contains),
"default resource ids must not collide across regions: " + usEastIds + " vs " + euWestIds);
// stability across two seeding runs (new storage)
Ec2Service service2 = new Ec2Service(mockConfig(true), mock(Ec2ContainerManager.class),
mock(Ec2PortForwardManager.class),
mock(AmiImageResolver.class), mock(Ec2ImageCatalog.class), new Ec2InstanceTypeCatalog(),
new InMemoryStorageFactory());
assertEquals(usEastIds, defaultResourceIds(service2, "us-east-1"));
}
/** Every default resource id of one region, in a fixed order: gateway, route table, its
* first association, the default ACL, its first association and the VPC CIDR association. */
private static List<String> defaultResourceIds(Ec2Service service, String region) {
List<String> ids = new ArrayList<>();
ids.add(service.describeInternetGateways(region, List.of(), Map.of()).getFirst().getInternetGatewayId());
RouteTable rt = service.describeRouteTables(region, List.of(), Map.of()).getFirst();
ids.add(rt.getRouteTableId());
ids.add(rt.getAssociations().getFirst().getRouteTableAssociationId());
NetworkAcl acl = service.describeNetworkAcls(region, List.of(), Map.of()).stream()
.filter(NetworkAcl::isDefault).findFirst().orElseThrow();
ids.add(acl.getNetworkAclId());
ids.add(acl.getAssociations().getFirst().getNetworkAclAssociationId());
ids.add(service.describeVpcs(region, List.of(), Map.of()).getFirst()
.getCidrBlockAssociationSet().getFirst().getAssociationId());
return ids;
}
private static boolean isHex17(String s) {
if (s == null || s.length() != 17) {
return false;
}
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
return false;
}
}
return true;
}
@Test
void resolveDefaultVpcIdFallsBackToPreRegionScopingStorage() throws Exception {
// Existing regions are not re-seeded, so persisted VPCs can still have the old unscoped id.
@@ -43,7 +43,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
class EcsAwsvpcTaskAddressDockerIntegrationTest {
private static final String REGION = "us-east-1";
private static final String SUBNET = "subnet-default-us-east-1-a";
private static final String SUBNET = Ec2Service.defaultSubnetId("us-east-1", "a");
private static final int PORT = 8080;
/**
@@ -1,5 +1,6 @@
package io.floci.aws.services.ecs;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.services.ecs.model.ClusterSetting;
import io.floci.aws.testing.CfnStackWaits;
import io.floci.aws.testing.RestAssuredJsonUtils;
@@ -56,8 +57,8 @@ class EcsContainerInsightsIntegrationTest {
"Service": {"Type": "AWS::ECS::Service", "Properties": {"ServiceName": "web",
"Cluster": {"Ref": "Cluster"}, "TaskDefinition": {"Ref": "TaskDef"},
"DesiredCount": 1, "LaunchType": "FARGATE", "NetworkConfiguration": {"AwsvpcConfiguration":
{"Subnets": ["subnet-default-us-east-1-a"]}}}}}}
""".formatted(cluster);
{"Subnets": ["%2$s"]}}}}}}
""".formatted(cluster, Ec2Service.defaultSubnetId("us-east-1", "a"));
given().contentType("application/x-www-form-urlencoded")
.formParam("Action", "CreateStack")
@@ -1,5 +1,6 @@
package io.floci.aws.services.ecs;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.path.json.config.JsonPathConfig;
@@ -116,9 +117,9 @@ class EcsDescribeServicesIntegrationTest {
Response created = call("CreateService", """
{"cluster":"blue-running-cluster","serviceName":"blue-running-service",
"taskDefinition":"blue-running-task","desiredCount":1,"launchType":"FARGATE",
"networkConfiguration":{"awsvpcConfiguration":{"subnets":["subnet-default-us-east-1-a"]}},
"networkConfiguration":{"awsvpcConfiguration":{"subnets":["%s"]}},
"deploymentController":{"type":"CODE_DEPLOY"}}
""");
""".formatted(Ec2Service.defaultSubnetId("us-east-1", "a")));
String primaryId = created.path("service.taskSets[0].id");
await().atMost(Duration.ofSeconds(30)).untilAsserted(() ->
describe("blue-running-cluster", "blue-running-service").then()
@@ -1,5 +1,6 @@
package io.floci.aws.services.ecs;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
@@ -40,7 +41,7 @@ class EcsExecuteCommandIntegrationTest {
private static final String CLUSTER = "exec-cluster";
private static final String NETWORK =
"\"networkConfiguration\":{\"awsvpcConfiguration\":{\"subnets\":"
+ "[\"subnet-default-us-east-1-a\"]}}";
+ "[\"" + Ec2Service.defaultSubnetId("us-east-1", "a") + "\"]}}";
@BeforeAll
static void configure() {
@@ -1,5 +1,6 @@
package io.floci.aws.services.ecs;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
@@ -37,7 +38,7 @@ class EcsFargateEdgeCaseIntegrationTest {
private static final String CLUSTER = "fargate-edge-cluster";
private static final String NETWORK =
"\"networkConfiguration\":{\"awsvpcConfiguration\":{\"subnets\":"
+ "[\"subnet-default-us-east-1-a\"]}}";
+ "[\"" + Ec2Service.defaultSubnetId("us-east-1", "a") + "\"]}}";
@BeforeAll
static void configure() {
@@ -446,7 +447,7 @@ class EcsFargateEdgeCaseIntegrationTest {
call("RunTask", "{\"cluster\":\"" + CLUSTER + "\",\"taskDefinition\":\"" + family
+ "\",\"launchType\":\"FARGATE\",\"networkConfiguration\":{\"awsvpcConfiguration\":"
+ "{\"subnets\":[\"subnet-default-us-east-1-a\"],\"securityGroups\":[\"sg-nope\"]}}}", 400)
+ "{\"subnets\":[\"" + Ec2Service.defaultSubnetId("us-east-1", "a") + "\"],\"securityGroups\":[\"sg-nope\"]}}}", 400)
.then()
.body("__type", containsString("InvalidParameterException"))
.body("message", containsString("sg-nope"));
@@ -778,7 +779,7 @@ class EcsFargateEdgeCaseIntegrationTest {
// A changed network configuration starts new tasks, so it rolls.
call("UpdateService", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-roll-svc\","
+ "\"networkConfiguration\":{\"awsvpcConfiguration\":{\"subnets\":"
+ "[\"subnet-default-us-east-1-b\"]}}}", 200);
+ "[\"" + Ec2Service.defaultSubnetId("us-east-1", "b") + "\"]}}}", 200);
assertNotEquals(initial, deploymentId("edge-roll-svc"),
"a changed network configuration must roll the deployment");
@@ -1070,7 +1071,7 @@ class EcsFargateEdgeCaseIntegrationTest {
+ "\"launchType\":\"FARGATE\",\"externalId\":\"d-EXAMPLE\","
+ "\"scale\":{\"value\":50,\"unit\":\"PERCENT\"},"
+ "\"networkConfiguration\":{\"awsvpcConfiguration\":{\"subnets\":"
+ "[\"subnet-default-us-east-1-a\"]}},"
+ "[\"" + Ec2Service.defaultSubnetId("us-east-1", "a") + "\"]}},"
+ "\"loadBalancers\":[{\"targetGroupArn\":\"arn:aws:elasticloadbalancing:us-east-1:"
+ "000000000000:targetgroup/tg/1\",\"containerName\":\"app\",\"containerPort\":80}],"
+ "\"tags\":[{\"key\":\"team\",\"value\":\"platform\"}]}", 200);
@@ -1,5 +1,6 @@
package io.floci.aws.services.ecs;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
@@ -31,7 +32,7 @@ class EcsFargateTaskIntegrationTest {
private static final String TARGET = "AmazonEC2ContainerServiceV20141113.";
private static final String CT = "application/x-amz-json-1.1";
private static final String CLUSTER = "fargate-task-cluster";
private static final String SUBNET = "subnet-default-us-east-1-a";
private static final String SUBNET = Ec2Service.defaultSubnetId("us-east-1", "a");
private static final String NETWORK =
"\"networkConfiguration\":{\"awsvpcConfiguration\":{\"subnets\":[\"" + SUBNET + "\"]}}";
@@ -1,5 +1,6 @@
package io.floci.aws.services.ecs;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.specification.RequestSpecification;
@@ -457,10 +458,10 @@ class EcsIntegrationTest {
"cluster": "%s",
"taskDefinition": "%s",
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}},
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}},
"count": 1
}
""".formatted(CLUSTER_NAME, TASK_DEF_FAMILY))
""".formatted(CLUSTER_NAME, TASK_DEF_FAMILY, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -547,10 +548,10 @@ class EcsIntegrationTest {
"cluster": "%s",
"taskDefinition": "empty-containers-task",
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}},
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}},
"count": 1
}
""".formatted(CLUSTER_NAME))
""".formatted(CLUSTER_NAME, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -701,13 +702,13 @@ class EcsIntegrationTest {
"taskDefinition": "%s",
"desiredCount": 1,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}},
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}},
"tags": [
{"key": "Environment", "value": "dev"},
{"key": "Project", "value": "project1"}
]
}
""".formatted(CLUSTER_NAME, SERVICE_NAME, TASK_DEF_FAMILY))
""".formatted(CLUSTER_NAME, SERVICE_NAME, TASK_DEF_FAMILY, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -796,9 +797,9 @@ class EcsIntegrationTest {
"taskDefinition": "%s",
"desiredCount": 2,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}}
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}}
}
""".formatted(CLUSTER_NAME, SERVICE_NAME, TASK_DEF_FAMILY))
""".formatted(CLUSTER_NAME, SERVICE_NAME, TASK_DEF_FAMILY, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -818,9 +819,9 @@ class EcsIntegrationTest {
"taskDefinition": "%s",
"desiredCount": 99,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}}
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}}
}
""".formatted(CLUSTER_NAME, SERVICE_NAME, TASK_DEF_FAMILY))
""".formatted(CLUSTER_NAME, SERVICE_NAME, TASK_DEF_FAMILY, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -842,9 +843,9 @@ class EcsIntegrationTest {
"taskDefinition": "%s",
"desiredCount": -5,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}}
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}}
}
""".formatted(CLUSTER_NAME, TASK_DEF_FAMILY))
""".formatted(CLUSTER_NAME, TASK_DEF_FAMILY, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -885,9 +886,9 @@ class EcsIntegrationTest {
"taskDefinition": "%s",
"desiredCount": 0,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}}
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}}
}
""".formatted(CLUSTER_NAME, TASK_DEF_FAMILY))
""".formatted(CLUSTER_NAME, TASK_DEF_FAMILY, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -1112,9 +1113,9 @@ class EcsIntegrationTest {
"taskDefinition": "review-td",
"desiredCount": 1,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}}
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}}
}
""".formatted(REVIEW_CLUSTER, REVIEW_SERVICE))
""".formatted(REVIEW_CLUSTER, REVIEW_SERVICE, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -1198,7 +1199,7 @@ class EcsIntegrationTest {
"taskDefinition": "review-td",
"desiredCount": 1,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}},
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}},
"loadBalancers": [
{
"targetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:000000000000:targetgroup/tg-a/1234",
@@ -1207,7 +1208,7 @@ class EcsIntegrationTest {
}
]
}
""".formatted(REVIEW_CLUSTER, REVIEW_LB_SERVICE))
""".formatted(REVIEW_CLUSTER, REVIEW_LB_SERVICE, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -1223,7 +1224,7 @@ class EcsIntegrationTest {
"taskDefinition": "review-td",
"desiredCount": 1,
"launchType": "FARGATE",
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["subnet-default-us-east-1-a"]}},
"networkConfiguration": {"awsvpcConfiguration": {"subnets": ["%s"]}},
"loadBalancers": [
{
"targetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:000000000000:targetgroup/tg-DIFFERENT/9999",
@@ -1232,7 +1233,7 @@ class EcsIntegrationTest {
}
]
}
""".formatted(REVIEW_CLUSTER, REVIEW_LB_SERVICE))
""".formatted(REVIEW_CLUSTER, REVIEW_LB_SERVICE, Ec2Service.defaultSubnetId("us-east-1", "a")))
.when()
.post("/")
.then()
@@ -5,6 +5,7 @@ import com.github.dockerjava.api.model.ContainerNetwork;
import io.floci.aws.services.cloudmap.CloudMapService;
import io.floci.aws.services.cloudmap.model.Operation;
import io.floci.aws.services.cloudmap.model.Service;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.services.ecs.model.AwsVpcConfiguration;
import io.floci.aws.services.ecs.model.ContainerDefinition;
import io.floci.aws.services.ecs.model.CreateServiceRequest;
@@ -44,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
class EcsServiceDiscoveryDockerIntegrationTest {
private static final String REGION = "us-east-1";
private static final String SUBNET = "subnet-default-us-east-1-a";
private static final String SUBNET = Ec2Service.defaultSubnetId("us-east-1", "a");
private static final String BUSYBOX_IMAGE = TestImages.BUSYBOX;
private static final String CONTAINER_NAME = "app";
private static final String CLOUD_MAP_SERVICE_NAME = "cache";
@@ -1,5 +1,6 @@
package io.floci.aws.services.ecs;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.AwsTestClients;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
@@ -141,7 +142,7 @@ class EcsServicePlatformVersionIntegrationTest {
CreateServiceRequest.Builder request = CreateServiceRequest.builder().cluster(cluster).serviceName(SERVICE)
.taskDefinition(taskDefinition).desiredCount(desiredCount).platformVersion(platformVersion)
.networkConfiguration(NetworkConfiguration.builder().awsvpcConfiguration(network -> network
.subnets("subnet-default-us-east-1-a")).build());
.subnets(Ec2Service.defaultSubnetId("us-east-1", "a"))).build());
if (provider == null) {
request.launchType("FARGATE");
} else {
@@ -79,7 +79,7 @@ class EcsTaskMetadataControllerTest {
private static Subnet subnet() {
Subnet subnet = new Subnet();
subnet.setSubnetId("subnet-default-us-east-1-a");
subnet.setSubnetId(Ec2Service.defaultSubnetId("us-east-1", "a"));
subnet.setVpcId("vpc-0a1b2c3d");
subnet.setCidrBlock("172.31.32.0/20");
subnet.setAvailabilityZone("us-east-1a");
@@ -116,7 +116,7 @@ class EcsTaskMetadataControllerTest {
task.setPrivateDnsName("ip-172-31-0-42.ec2.internal");
AwsVpcConfiguration awsvpc = new AwsVpcConfiguration();
awsvpc.setSubnets(List.of("subnet-default-us-east-1-a"));
awsvpc.setSubnets(List.of(Ec2Service.defaultSubnetId("us-east-1", "a")));
NetworkConfiguration networkConfiguration = new NetworkConfiguration();
networkConfiguration.setAwsvpcConfiguration(awsvpc);
task.setNetworkConfiguration(networkConfiguration);
@@ -1,5 +1,6 @@
package io.floci.aws.services.elbv2;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.AwsTestClients;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.params.ParameterizedTest;
@@ -87,7 +88,7 @@ class ElbV2ListenerLookupIntegrationTest {
private static String createBalancer(ElasticLoadBalancingV2Client client, String prefix) {
return client.createLoadBalancer(r -> r.name(prefix + "-" + UUID.randomUUID().toString().substring(0, 8))
.type("application").subnets(List.of("subnet-default-us-east-1-a", "subnet-default-us-east-1-b")))
.type("application").subnets(List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b"))))
.loadBalancers().get(0).loadBalancerArn();
}
@@ -1,5 +1,6 @@
package io.floci.aws.services.elbv2;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.AwsTestClients;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
@@ -26,7 +27,7 @@ class ElbV2RuleLookupIntegrationTest {
ElasticLoadBalancingV2Client.builder(), "000000000000", Region.US_EAST_1)) {
String balancer = client.createLoadBalancer(r -> r
.name("sdk-rule-" + UUID.randomUUID().toString().substring(0, 8))
.type("application").subnets(List.of("subnet-default-us-east-1-a", "subnet-default-us-east-1-b")))
.type("application").subnets(List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b"))))
.loadBalancers().get(0).loadBalancerArn();
try {
String listener = client.createListener(r -> r.loadBalancerArn(balancer).port(8080).protocol("HTTP")
@@ -1,5 +1,6 @@
package io.floci.aws.services.eventbridge;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.specification.RequestSpecification;
@@ -69,15 +70,15 @@ class EventBridgeEcsRunTaskIntegrationTest {
"Group": "eb-ecs-group-%s",
"NetworkConfiguration": {
"awsvpcConfiguration": {
"Subnets": ["subnet-default-us-east-1-a", "subnet-default-us-east-1-b"],
"SecurityGroups": ["sg-default-us-east-1"],
"Subnets": ["%s", "%s"],
"SecurityGroups": ["%s"],
"AssignPublicIp": "ENABLED"
}
}
}
}]
}
""".formatted(ruleName, clusterArn, taskDefinitionArn, suffix))
""".formatted(ruleName, clusterArn, taskDefinitionArn, suffix, Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b"), Ec2Service.defaultSecurityGroupId("us-east-1")))
.when()
.post("/")
.then()
@@ -100,9 +101,9 @@ class EventBridgeEcsRunTaskIntegrationTest {
.body("Targets[0].EcsParameters.LaunchType", equalTo("FARGATE"))
.body("Targets[0].EcsParameters.Group", equalTo("eb-ecs-group-" + suffix))
.body("Targets[0].EcsParameters.NetworkConfiguration.awsvpcConfiguration.Subnets",
hasItem("subnet-default-us-east-1-a"))
hasItem(Ec2Service.defaultSubnetId("us-east-1", "a")))
.body("Targets[0].EcsParameters.NetworkConfiguration.awsvpcConfiguration.SecurityGroups",
hasItem("sg-default-us-east-1"))
hasItem(Ec2Service.defaultSecurityGroupId("us-east-1")))
.body("Targets[0].EcsParameters.NetworkConfiguration.awsvpcConfiguration.AssignPublicIp",
equalTo("ENABLED"));
@@ -3,6 +3,7 @@ package io.floci.aws.services.iam;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.testing.EnforcementFixtures;
import io.floci.aws.testing.IamEnforcementProfile;
import io.floci.aws.testing.PartitionCleanup;
@@ -1102,16 +1103,17 @@ class IamPassRoleEnforcementIntegrationTest {
private static String runTask(String cluster, String family, String taskRoleOverride) {
return """
{"cluster":"%s","taskDefinition":"%s","launchType":"FARGATE","count":1,
"networkConfiguration":{"awsvpcConfiguration":{"subnets":["subnet-default-us-east-1-a"]}}%s}"""
.formatted(cluster, family, taskRoleOverride == null ? ""
"networkConfiguration":{"awsvpcConfiguration":{"subnets":["%s"]}}%s}"""
.formatted(cluster, family, Ec2Service.defaultSubnetId("us-east-1", "a"),
taskRoleOverride == null ? ""
: ",\"overrides\":{\"taskRoleArn\":\"" + taskRoleOverride + "\"}");
}
private static String service(String cluster, String name, String family) {
return """
{"cluster":"%s","serviceName":"%s","taskDefinition":"%s","desiredCount":0,"launchType":"FARGATE",
"networkConfiguration":{"awsvpcConfiguration":{"subnets":["subnet-default-us-east-1-a"]}}}"""
.formatted(cluster, name, family);
"networkConfiguration":{"awsvpcConfiguration":{"subnets":["%s"]}}}"""
.formatted(cluster, name, family, Ec2Service.defaultSubnetId("us-east-1", "a"));
}
private static RequestSpecification createStack(User user, String stack) {
@@ -3,6 +3,7 @@ package io.floci.aws.services.rds;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.services.docdb.DocDbQueryHandler;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.services.neptune.NeptuneQueryHandler;
import io.floci.aws.services.rds.export.RdsExportTaskService;
import io.floci.aws.services.rds.model.DatabaseEngine;
@@ -3526,8 +3527,8 @@ class RdsQueryHandlerTest {
group.setDbSubnetGroupArn("arn:aws:rds:us-east-1:123456789012:subgrp:default");
group.setVpcId("vpc-default");
group.setSubnetGroupStatus("Complete");
group.setSubnetIds(List.of("subnet-default-a", "subnet-default-b"));
group.setSubnetAvailabilityZones(Map.of("subnet-default-a", "us-east-1a", "subnet-default-b", "us-east-1b"));
group.setSubnetIds(List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
group.setSubnetAvailabilityZones(Map.of(Ec2Service.defaultSubnetId("us-east-1", "a"), "us-east-1a", Ec2Service.defaultSubnetId("us-east-1", "b"), "us-east-1b"));
return group;
}
@@ -134,7 +134,7 @@ class RdsServiceTest {
private static final String PROXY_ROLE_ARN = "arn:aws:iam::123456789012:role/proxy";
private static final List<String> PROXY_SUBNET_IDS =
List.of("subnet-default-a", "subnet-default-b");
List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b"));
private static final List<DbProxyAuth> PROXY_AUTH = List.of(new DbProxyAuth(
"SECRETS", "arn:aws:secretsmanager:us-east-1:123456789012:secret:db-AbCdEf",
"DISABLED", null, null));
@@ -3074,7 +3074,7 @@ class RdsServiceTest {
@Test
void createDbInstanceOmittedPubliclyAccessibleDefaultsFalseForNamedNonDefaultSubnetGroup() {
rdsService.createDbSubnetGroup("custom-subnets", "test", List.of("subnet-default-a", "subnet-default-b"));
rdsService.createDbSubnetGroup("custom-subnets", "test", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
DbInstance instance = rdsService.createDbInstance("custom-subnet-db", "postgres", "13",
"admin", "password", "dbname", "db.t3.micro",
@@ -4969,10 +4969,10 @@ class RdsServiceTest {
@Test
void dbSubnetGroupRoundTrip() {
DbSubnetGroup group = rdsService.createDbSubnetGroup(
"sample-db-subnets", "test", List.of("subnet-default-a", "subnet-default-b"));
"sample-db-subnets", "test", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
assertEquals("sample-db-subnets", group.getDbSubnetGroupName());
assertEquals(List.of("subnet-default-a", "subnet-default-b"), group.getSubnetIds());
assertEquals(List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")), group.getSubnetIds());
assertEquals(1, rdsService.listDbSubnetGroups("sample-db-subnets").size());
rdsService.deleteDbSubnetGroup("sample-db-subnets");
@@ -5000,7 +5000,7 @@ class RdsServiceTest {
@Test
void dbSubnetGroupTagsRoundTripAndMutateByArn() {
rdsService.createDbSubnetGroup(
"sample-db-subnets", "test", List.of("subnet-default-a", "subnet-default-b"));
"sample-db-subnets", "test", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
String arn = "arn:aws:rds:us-east-1:123456789012:subgrp:sample-db-subnets";
// A subnet group with no tags must list cleanly — previously this threw DBInstanceNotFound (404)
@@ -5018,11 +5018,11 @@ class RdsServiceTest {
@Test
void dbSubnetGroupTagsSurviveModify() {
rdsService.createDbSubnetGroup(
"sample-db-subnets", "test", List.of("subnet-default-a", "subnet-default-b"));
"sample-db-subnets", "test", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
String arn = "arn:aws:rds:us-east-1:123456789012:subgrp:sample-db-subnets";
rdsService.addTagsToResource(arn, Map.of("Name", "sample-db-subnets"));
rdsService.modifyDbSubnetGroup("sample-db-subnets", List.of("subnet-default-a"));
rdsService.modifyDbSubnetGroup("sample-db-subnets", List.of(Ec2Service.defaultSubnetId("us-east-1", "a")));
assertEquals(Map.of("Name", "sample-db-subnets"),
rdsService.listTagsForResource(arn));
@@ -6652,7 +6652,7 @@ class RdsServiceTest {
new InMemoryStorage<>();
DbSubnetGroup subnetGroup = new DbSubnetGroup(
"legacy-subnets", "legacy", "vpc-default", PROXY_SUBNET_IDS,
Map.of("subnet-default-a", "us-east-1a", "subnet-default-b", "us-east-1b"));
Map.of(Ec2Service.defaultSubnetId("us-east-1", "a"), "us-east-1a", Ec2Service.defaultSubnetId("us-east-1", "b"), "us-east-1b"));
subnetGroup.setDbSubnetGroupArn(
"arn:aws:rds:us-east-1:" + accountId + ":subgrp:legacy-subnets");
rawSubnetGroups.put("legacy-subnets", subnetGroup);
@@ -6752,10 +6752,10 @@ class RdsServiceTest {
@Test
void createDbSubnetGroupRejectsDuplicateWithModelCode() {
rdsService.createDbSubnetGroup("my-subnet-group", "desc", List.of("subnet-default-a", "subnet-default-b"));
rdsService.createDbSubnetGroup("my-subnet-group", "desc", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
AwsException exception = assertThrows(AwsException.class, () ->
rdsService.createDbSubnetGroup("my-subnet-group", "desc", List.of("subnet-default-a", "subnet-default-b")));
rdsService.createDbSubnetGroup("my-subnet-group", "desc", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b"))));
assertEquals("DBSubnetGroupAlreadyExists", exception.getErrorCode());
}
@@ -6763,7 +6763,7 @@ class RdsServiceTest {
@Test
void createDbSubnetGroupPopulatesArn() {
DbSubnetGroup group = rdsService.createDbSubnetGroup("my-subnet-group", "desc",
List.of("subnet-default-a", "subnet-default-b"));
List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
assertEquals("arn:aws:rds:us-east-1:123456789012:subgrp:my-subnet-group", group.getDbSubnetGroupArn());
}
@@ -6829,7 +6829,7 @@ class RdsServiceTest {
@Test
void resolveDbSubnetGroupViewReturnsStoredCustomGroup() {
rdsService.createDbSubnetGroup("my-subnet-group", "desc", List.of("subnet-default-a", "subnet-default-b"));
rdsService.createDbSubnetGroup("my-subnet-group", "desc", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")));
DbSubnetGroup group = rdsService.resolveDbSubnetGroupView("my-subnet-group");
@@ -11443,8 +11443,8 @@ class RdsServiceTest {
private static List<Subnet> defaultSubnets() {
return List.of(
subnet("subnet-default-a", "vpc-default", "us-east-1a"),
subnet("subnet-default-b", "vpc-default", "us-east-1b"));
subnet(Ec2Service.defaultSubnetId("us-east-1", "a"), "vpc-default", "us-east-1a"),
subnet(Ec2Service.defaultSubnetId("us-east-1", "b"), "vpc-default", "us-east-1b"));
}
private static DbInstance persistedInstance(
@@ -11520,7 +11520,7 @@ class RdsServiceTest {
@Test
void createDbSubnetGroupStoresTheTagsItIsGiven() {
rdsService.createDbSubnetGroup("tagged", "d", List.of("subnet-default-a", "subnet-default-b"), "us-east-1",
rdsService.createDbSubnetGroup("tagged", "d", List.of(Ec2Service.defaultSubnetId("us-east-1", "a"), Ec2Service.defaultSubnetId("us-east-1", "b")), "us-east-1",
Map.of("Name", "tagged", "env", "tst"));
String arn = "arn:aws:rds:us-east-1:123456789012:subgrp:tagged";
@@ -11538,7 +11538,7 @@ class RdsServiceTest {
@Test
void createDbSubnetGroupErrorNamesMissingSubnetIds() {
String subnetA = "subnet-default-a";
String subnetA = Ec2Service.defaultSubnetId("us-east-1", "a");
AwsException ex = assertThrows(AwsException.class, () ->
rdsService.createDbSubnetGroup("grp", "desc",