mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
feat(route53resolver): implement ListResolverEndpointIpAddresses (#5731)
* feat(route53resolver): implement ListResolverEndpointIpAddresses The Terraform provider lists an endpoint's IP addresses right after CreateResolverEndpoint, so the missing operation (UnknownOperationException) failed every aws_route53_resolver_endpoint create. Built from the IpAddresses recorded at create time: one ATTACHED entry per request with a deterministic rni- IpId. Unknown endpoint ids raise ResourceNotFoundException. Not paginated, like the sibling List operations. * docs(route53resolver): update service matrix operation count * refactor(route53resolver): add endpoint IP addresses with a single addAll * fix(route53resolver): distinct IpIds for repeated entries; fail on missing IP record ListResolverEndpointIpAddresses hashed only the endpoint id and the entry, so two identical entries (two addresses in one subnet, both left for AWS to pick, which IpAddressesRequest allows) shared an IpId. Include the entry's position in the recorded list, which is normalised once at create and so stable across reads. An endpoint whose recorded IP requests are missing returned an empty list beside a nonzero IpAddressCount. Throw the modeled InternalServiceErrorException instead. * test(route53resolver): import List/HashSet instead of fully qualifying (checkstyle NoFqcn) * fix(route53resolver): return InternalServiceErrorException as HTTP 400 The Route 53 Resolver model gives InternalServiceErrorException no httpStatusCode, so clients expect the awsJson default of 400, as with every other Resolver error.
This commit is contained in:
1 parent
5544a119d3
commit
a37c27516a
6 files changed
+161
-2
No files matched your search
+8
@@ -50,6 +50,8 @@ public class Route53ResolverJsonHandler {
|
||||
case "GetResolverEndpoint" -> resolverEndpointResponse(
|
||||
service.getResolverEndpoint(text(request, "ResolverEndpointId")));
|
||||
case "ListResolverEndpoints" -> handleListResolverEndpoints();
|
||||
case "ListResolverEndpointIpAddresses" -> handleListResolverEndpointIpAddresses(
|
||||
text(request, "ResolverEndpointId"));
|
||||
case "UpdateResolverEndpoint" -> resolverEndpointResponse(
|
||||
service.updateResolverEndpoint(text(request, "ResolverEndpointId"), request));
|
||||
|
||||
@@ -144,6 +146,12 @@ public class Route53ResolverJsonHandler {
|
||||
return Response.ok(result).build();
|
||||
}
|
||||
|
||||
private Response handleListResolverEndpointIpAddresses(String endpointId) {
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
result.putArray("IpAddresses").addAll(service.listResolverEndpointIpAddresses(endpointId));
|
||||
return Response.ok(result).build();
|
||||
}
|
||||
|
||||
// ---------- Resolver rules ----------
|
||||
|
||||
private Response resolverRuleResponse(ObjectNode rule) {
|
||||
|
||||
+34
-1
@@ -83,7 +83,7 @@ public class Route53ResolverService {
|
||||
* Kept beside the endpoint rather than on it: the modeled {@code ResolverEndpoint} shape
|
||||
* carries {@code IpAddressCount} and no IP list, and the handlers return the stored node
|
||||
* verbatim, so holding the addresses on the resource would put an unmodeled member on the
|
||||
* wire. Only the CreatorRequestId conflict check reads this.
|
||||
* wire. Read by the CreatorRequestId conflict check and ListResolverEndpointIpAddresses.
|
||||
*/
|
||||
private final StorageBackend<String, ObjectNode> endpointIpRequestStore;
|
||||
private final ObjectMapper objectMapper;
|
||||
@@ -239,6 +239,39 @@ public class Route53ResolverService {
|
||||
return endpointStore.scan(key -> true).stream().map(ObjectNode::deepCopy).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* The endpoint's addresses as AWS {@code IpAddressResponse} entries, built from the
|
||||
* {@code IpAddresses} recorded at create time. {@code IpId} is derived from the endpoint,
|
||||
* the entry and its position in the recorded list, so it is stable across calls. An
|
||||
* address the request left for AWS to pick has no {@code Ip}: Floci does not allocate
|
||||
* from the subnet.
|
||||
*/
|
||||
public List<ObjectNode> listResolverEndpointIpAddresses(String id) {
|
||||
ObjectNode endpoint = require(endpointStore, id, "resolver endpoint");
|
||||
// A missing record would otherwise read as an empty list beside a nonzero
|
||||
// IpAddressCount; fail loudly with the modeled InternalServiceErrorException instead.
|
||||
JsonNode recorded = endpointIpRequestStore.get(id)
|
||||
.map(node -> node.get("IpAddressRequests"))
|
||||
.filter(JsonNode::isArray)
|
||||
.orElseThrow(() -> new AwsException("InternalServiceErrorException",
|
||||
"No IP addresses recorded for resolver endpoint: " + id, 400));
|
||||
List<ObjectNode> addresses = new ArrayList<>();
|
||||
for (int i = 0; i < recorded.size(); i++) {
|
||||
JsonNode request = recorded.get(i);
|
||||
ObjectNode address = objectMapper.createObjectNode();
|
||||
// The index keeps repeated entries (two addresses in one subnet, both left for AWS
|
||||
// to pick) distinct; the stored list is normalised once at create, so it is stable.
|
||||
address.put("IpId", "rni-" + deterministicHex(id + "|" + i + "|" + canonicalKey(request), 17));
|
||||
copyIfPresent(request, address, "SubnetId", "Ip", "Ipv6");
|
||||
address.put("Status", "ATTACHED");
|
||||
address.put("StatusMessage", "This IP address is operational.");
|
||||
address.set("CreationTime", endpoint.get("CreationTime"));
|
||||
address.set("ModificationTime", endpoint.get("CreationTime"));
|
||||
addresses.add(address);
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
public ObjectNode updateResolverEndpoint(String id, JsonNode request) {
|
||||
ObjectNode endpoint = require(endpointStore, id, "resolver endpoint");
|
||||
String endpointType = text(request, "ResolverEndpointType");
|
||||
|
||||
Reference in new issue
Block a user