fix(ec2): list the DynamoDB gateway endpoint service in DescribeVpcEndpointServices (#9016)

* fix(ec2): list the DynamoDB gateway endpoint service in DescribeVpcEndpointServices
This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-11-19 18:44:04 -04:00
1 parent b6af0646d5
commit a25c0435ee
6 files changed
+100 -18

No files matched your search

+4 -3
View File
@@ -156,9 +156,10 @@ a colon in that setting. Existing stored namespaces are not migrated or deleted
are `com.amazonaws.<region>.<service>` everywhere, except the (region, service) pairs the CDK
lists for China, ISO and EUSC, which reverse the DNS suffix (`cn.com.amazonaws.cn-north-1.lambda`).
GovCloud keeps `com.amazonaws`. Gateway endpoints and their AWS-managed prefix lists (S3,
DynamoDB) are `com.amazonaws.<region>.<service>` in every partition. S3 offers both kinds: where
the two names agree it is one service carrying both types, and in China it is listed twice, the
gateway `com.amazonaws.cn-north-1.s3` and the interface `cn.com.amazonaws.cn-north-1.s3`.
DynamoDB) are `com.amazonaws.<region>.<service>` in every partition. Both offer both kinds: where
the two names agree it is one service carrying both types, and where they differ (S3 in China) it
is listed twice, the gateway `com.amazonaws.cn-north-1.s3` and the interface
`cn.com.amazonaws.cn-north-1.s3`.
- **Lambda runtime images** pull from ECR Public (`public.ecr.aws`), which exists only in the
commercial partition; point `FLOCI_SERVICES_LAMBDA_ECR_BASE_URI` at a mirror elsewhere.
- **WAF `CLOUDFRONT` scope**: available only where CloudFront exists (`aws`, `aws-cn`), and its
+1 -1
View File
@@ -430,7 +430,7 @@ naming different VPCs find nothing.
| DescribeDhcpOptions | Lists DHCP options sets by ID or filters, with paginated results. |
| AssociateDhcpOptions | Associates an options set with a VPC; `default` leaves the VPC with no DHCP options. |
| DeleteDhcpOptions | Deletes an unassociated DHCP options set. |
| DescribeVpcEndpointServices | Lists common AWS interface endpoint services and S3 (gateway and interface) in every availability zone, named per partition (see [Partitions](../configuration/partitions.md)). A `ServiceName` filter is echoed back as asked. |
| DescribeVpcEndpointServices | Lists common AWS interface endpoint services, and S3 and DynamoDB (gateway and interface), in every availability zone, named per partition (see [Partitions](../configuration/partitions.md)). A `ServiceName` filter is echoed back as asked. |
| CreateVpcEndpoint | Creates a VPC endpoint record, including its `PolicyDocument` and the per-subnet IPv4 and IPv6 addresses named by `SubnetConfiguration.N`. `IpAddressType` defaults to `ipv4`. Interface and gateway address types are stored as metadata. Synthesized endpoint interfaces still carry IPv4 only; IPv6 networking is not emulated. An `Ipv4` value outside the named subnet's CIDR, or among the first four or the last address AWS reserves in it, is rejected with `InvalidParameterValue`. |
| DescribeVpcEndpoints | Lists or returns stored VPC endpoints, including their IP address type. |
| ModifyVpcEndpoint | Associates or disassociates route tables, subnets and security groups, sets or resets the endpoint policy, and updates stored `IpAddressType` metadata. Omitting the type preserves its current value; malformed types are rejected before changes are applied. `SubnetConfiguration.N` replaces the addresses pinned for a subnet, under the same address validation as CreateVpcEndpoint. `DnsOptions` is accepted and ignored. |
@@ -1977,6 +1977,9 @@ public class Ec2QueryHandler {
"elasticloadbalancing", "sns", "sqs", "kinesis-streams", "kinesis-firehose",
"states", "events", "lambda", "glue", "athena", "iot.data", "execute-api");
// The services AWS also offers as a Gateway endpoint, each named com.amazonaws.<region>.<name>.
private static final List<String> GATEWAY_ENDPOINT_SERVICES = List.of("s3", "dynamodb");
private Response handleDescribeVpcEndpointServices(MultivaluedMap<String, String> p, String region) {
List<String> requested = getList(p, "ServiceName");
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
@@ -2037,10 +2040,13 @@ public class Ec2QueryHandler {
private List<ServiceDetail> buildServiceDetails(String region, List<String> requested, List<String> azNames) {
List<ServiceDetail> services = new ArrayList<>();
// S3 is the one service with both offerings. The gateway keeps com.amazonaws in every
// partition; the interface takes the region's prefix, so in China the two are named apart.
String s3Gateway = "com.amazonaws." + region + ".s3";
String s3Interface = AwsRegionFacts.vpcEndpointServiceName(region, "s3");
// S3 and DynamoDB are the services with both offerings. The gateway keeps com.amazonaws in
// every partition; the interface takes the region's prefix, so in China S3's two are named apart.
Map<String, String> gatewayInterfaces = new LinkedHashMap<>();
for (String name : GATEWAY_ENDPOINT_SERVICES) {
gatewayInterfaces.put("com.amazonaws." + region + "." + name,
AwsRegionFacts.vpcEndpointServiceName(region, name));
}
// Requested service names are echoed verbatim, exactly as AWS does. The emulator
// supports any interface service in every AZ, so a requested (often custom) name
@@ -2053,22 +2059,23 @@ public class Ec2QueryHandler {
for (String name : INTERFACE_ENDPOINT_SERVICES) {
fullNames.add(AwsRegionFacts.vpcEndpointServiceName(region, name));
}
fullNames.add(s3Gateway);
if (!s3Interface.equals(s3Gateway)) {
fullNames.add(s3Interface);
for (Map.Entry<String, String> gateway : gatewayInterfaces.entrySet()) {
fullNames.add(gateway.getKey());
if (!gateway.getValue().equals(gateway.getKey())) {
fullNames.add(gateway.getValue());
}
}
}
for (String full : fullNames) {
List<String> serviceTypes;
if (full.equals(s3Interface) && !s3Interface.equals(s3Gateway)) {
String gatewayInterface = gatewayInterfaces.get(full);
if (gatewayInterface == null) {
serviceTypes = List.of("Interface");
} else if (full.endsWith(".s3")) {
serviceTypes = s3Interface.equals(s3Gateway)
? List.of("Gateway", "Interface")
: List.of("Gateway");
} else if (gatewayInterface.equals(full)) {
serviceTypes = List.of("Gateway", "Interface");
} else {
serviceTypes = List.of("Interface");
serviceTypes = List.of("Gateway");
}
services.add(new ServiceDetail(
full,
@@ -241,7 +241,8 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
"execute-api", "*.execute-api",
"ecs-agent", "ecs-a",
"ecs-telemetry", "ecs-t",
"data.iot", "");
"data.iot", "",
"dynamodb", "");
// A first launch may need to pull a large AMI-backed image. Keep a finite CloudFormation
// bound, but allow enough time for that legitimate cold-start path before cancellation.
private static final Duration CONTAINER_LAUNCH_TIMEOUT = Duration.ofMinutes(5);
@@ -0,0 +1,72 @@
package io.floci.aws.services.ec2;
import io.floci.aws.testing.AwsTestClients;
import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ec2.model.DescribeVpcEndpointServicesResponse;
import software.amazon.awssdk.services.ec2.model.Filter;
import software.amazon.awssdk.services.ec2.model.ServiceDetail;
import software.amazon.awssdk.services.ec2.model.ServiceTypeDetail;
import java.net.URI;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* DynamoDB is, with S3, one of the two services AWS offers as a Gateway endpoint, and it is also
* offered as an Interface endpoint. Terraform's aws_vpc_endpoint_service data source looks the
* service up with a {@code service-name} filter, so it has to be in the default catalog.
*/
@QuarkusTest
class Ec2DynamoDbEndpointServiceIntegrationTest {
private static final String DYNAMODB = "com.amazonaws.us-east-1.dynamodb";
@TestHTTPResource("/")
URI endpoint;
@Test
void aServiceNameFilterFindsTheDynamoDbGatewayAndInterfaceService() {
try (Ec2Client ec2 = client()) {
DescribeVpcEndpointServicesResponse response = ec2.describeVpcEndpointServices(r -> r.filters(
Filter.builder().name("service-name").values(DYNAMODB).build()));
assertEquals(List.of(DYNAMODB), response.serviceNames());
assertEquals(List.of("Gateway", "Interface"), serviceTypes(response.serviceDetails().get(0)));
}
}
@Test
void aGatewayServiceTypeFilterIncludesDynamoDb() {
try (Ec2Client ec2 = client()) {
DescribeVpcEndpointServicesResponse response = ec2.describeVpcEndpointServices(r -> r.filters(
Filter.builder().name("service-type").values("Gateway").build()));
assertThat(response.serviceNames(), hasItem(DYNAMODB));
}
}
@Test
void aRequestedDynamoDbServiceReportsBothEndpointTypes() {
try (Ec2Client ec2 = client()) {
DescribeVpcEndpointServicesResponse response =
ec2.describeVpcEndpointServices(r -> r.serviceNames(DYNAMODB));
assertEquals(List.of("Gateway", "Interface"), serviceTypes(response.serviceDetails().get(0)));
}
}
private static List<String> serviceTypes(ServiceDetail detail) {
return detail.serviceType().stream().map(ServiceTypeDetail::serviceTypeAsString).toList();
}
private Ec2Client client() {
return AwsTestClients.create(Ec2Client.builder(), "000000000000", Region.US_EAST_1, endpoint);
}
}
@@ -158,6 +158,7 @@ class Ec2VpcEndpointDnsEntriesIntegrationTest {
Map.entry("glue", "glue"),
Map.entry("athena", "athena"),
Map.entry("iot.data", ""),
Map.entry("dynamodb", ""),
Map.entry("execute-api", "*.execute-api"));
static Stream<Arguments> advertisedServicePrivateDnsNames() {