feat(ec2): implement DescribeSpotPriceHistory (#3359)

* feat(ec2): implement DescribeSpotPriceHistory

* test(ec2): verify DescribeSpotPriceHistory with SDK

* fix(ec2): honor spot price history dry run
This commit is contained in:
luiseterc authored and GitHub committed 2026-09-11 08:29:06 -04:00
1 parent 7c08b35f1d
commit ee23e26bc3
3 files changed
+66 -1

No files matched your search

@@ -171,7 +171,7 @@ public class AwsQueryController {
"DescribeAddressesAttribute",
"DescribeIamInstanceProfileAssociations",
"DescribeAvailabilityZones", "DescribeRegions", "DescribeAccountAttributes",
"DescribeInstanceTypes", "DescribeInstanceTypeOfferings",
"DescribeInstanceTypes", "DescribeInstanceTypeOfferings", "DescribeSpotPriceHistory",
"CreateLaunchTemplate", "CreateLaunchTemplateVersion", "DescribeLaunchTemplates", "DescribeLaunchTemplateVersions",
"ModifyLaunchTemplate", "DeleteLaunchTemplate",
"DescribeNetworkInterfaces",
@@ -256,6 +256,7 @@ public class Ec2QueryHandler {
case "RequestSpotInstances" -> handleRequestSpotInstances(params, region);
case "DescribeSpotInstanceRequests" -> handleDescribeSpotInstanceRequests(params, region);
case "CancelSpotInstanceRequests" -> handleCancelSpotInstanceRequests(params, region);
case "DescribeSpotPriceHistory" -> handleDescribeSpotPriceHistory(params, region);
// IPAM
case "EnableIpamOrganizationAdminAccount" -> handleEnableIpamOrgAdmin(params);
case "DisableIpamOrganizationAdminAccount" -> handleDisableIpamOrgAdmin(params);
@@ -5376,6 +5377,25 @@ public class Ec2QueryHandler {
return xmlResponse(xml.build());
}
/**
* Return the EC2 Query response shape for spot price history.
*
* <p>Floci does not currently maintain a spot-price snapshot. AWS returns an empty
* {@code spotPriceHistorySet} when no matching records exist, which is sufficient for
* clients such as Karpenter to distinguish an empty result from an unsupported action.</p>
*/
private Response handleDescribeSpotPriceHistory(MultivaluedMap<String, String> p, String region) {
checkDryRun(p);
XmlBuilder xml = new XmlBuilder()
.start("DescribeSpotPriceHistoryResponse", AwsNamespaces.EC2)
.elem("requestId", UUID.randomUUID().toString())
.elem("nextToken", "")
.start("spotPriceHistorySet")
.end("spotPriceHistorySet")
.end("DescribeSpotPriceHistoryResponse");
return xmlResponse(xml.build());
}
private String spotInstanceRequestXml(SpotInstanceRequest sir) {
XmlBuilder xml = new XmlBuilder()
.elem("spotInstanceRequestId", sir.getSpotInstanceRequestId())