fix(rds): store and describe Iops and StorageThroughput on DB instances (#8777)

CreateDBInstance and ModifyDBInstance accepted Iops and StorageThroughput but dropped them, and DescribeDBInstances returned neither, so a Terraform aws_db_instance that set iops or storage_throughput never converged. Both are now stored from Create and Modify. Describe reports Iops on io1, io2 and gp3 and StorageThroughput on gp3, with the RDS User Guide's gp3 baseline when an instance named neither (12,000 IOPS and 500 MiB/s from 400 GiB, 200 GiB for Oracle, never for SQL Server; 3,000 and 125 otherwise), and StorageThroughput 0 on every other type. Iops on a type without provisioned IOPS, Iops=0 aside, and StorageThroughput off gp3 are refused with InvalidParameterCombination, a create naming Iops and no type defaults to io1, and a type switch drops values the new type does not carry.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-11-19 13:02:39 -04:00
1 parent 623be62f3a
commit 079d4a2813
7 files changed
+285 -10

No files matched your search

+7 -2
View File
@@ -592,12 +592,17 @@ restores, point-in-time copies and read replicas. It also survives persistent, h
reloads. Legacy records without the member retain the existing `gp2` fallback.
Storage type changes apply immediately to control-plane metadata; the backing container volume's
performance is unchanged. `Iops`, `StorageThroughput` and `MultiAZ` changes remain unimplemented.
performance is unchanged. `MultiAZ` changes remain unimplemented. `Iops` and `StorageThroughput` are stored from Create and
Modify and described for the storage types that carry them (`Iops` on io1, io2 and gp3, throughput on gp3);
every other type reports `StorageThroughput` as `0`; a gp3 instance that named neither reports the
[gp3 baseline](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html#gp3-storage).
`Iops` on a type without provisioned IOPS (`Iops=0` is allowed) and `StorageThroughput` on any type but gp3 are
refused with `InvalidParameterCombination`; a create that names `Iops` and no type defaults to io1.
Omitted create requests retain Floci's existing `gp2` default, which differs from the current
[AWS create default](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html).
Floci's snapshot and point-in-time copies inherit the source type when the request omits it, rather
than applying the [AWS restore default](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceFromDBSnapshot.html).
Floci does not enforce every engine-specific storage allocation, IOPS restriction or regional
Floci does not enforce every engine-specific storage allocation, IOPS range or ratio, or regional
storage-type availability. Magnetic `standard` storage is refused.
### Storage autoscaling threshold changes
@@ -996,7 +996,9 @@ public class RdsQueryHandler {
optionalInt(params.getFirst("MaxAllocatedStorage")),
params.getFirst("StorageType"),
params.getFirst("CACertificateIdentifier"),
params.getFirst("LicenseModel"));
params.getFirst("LicenseModel"),
optionalInt(params.getFirst("Iops")),
optionalInt(params.getFirst("StorageThroughput")));
}
/**
@@ -3408,6 +3410,8 @@ public class RdsQueryHandler {
.elem("MultiAZ", i.isMultiAz())
.elem("AutoMinorVersionUpgrade", i.isAutoMinorVersionUpgrade())
.elem("StorageType", i.getStorageType())
.elem("Iops", iops(i))
.elem("StorageThroughput", storageThroughput(i))
.elem("PubliclyAccessible", i.isPubliclyAccessible())
.elem("AvailabilityZone", i.getAvailabilityZone() != null ? i.getAvailabilityZone() : config.defaultAvailabilityZone())
.elem("PreferredMaintenanceWindow", i.getPreferredMaintenanceWindow() != null
@@ -3501,6 +3505,41 @@ public class RdsQueryHandler {
return xml.build();
}
/** Iops as Describe reports it: on io1, io2 and gp3, the stored value, else the gp3 baseline. */
private static String iops(DbInstance i) {
String type = i.getStorageType();
boolean gp3 = "gp3".equals(type);
if (!gp3 && !"io1".equals(type) && !"io2".equals(type)) {
return null;
}
if (i.getIops() != null) {
return i.getIops().toString();
}
return gp3 ? (gp3BaselineSteppedUp(i) ? "12000" : "3000") : null;
}
/** StorageThroughput as Describe reports it: on gp3 the stored value, else the baseline; 0 on any other type. */
private static String storageThroughput(DbInstance i) {
if (!"gp3".equals(i.getStorageType())) {
return "0";
}
if (i.getStorageThroughput() != null) {
return i.getStorageThroughput().toString();
}
return gp3BaselineSteppedUp(i) ? "500" : "125";
}
/**
* Whether the gp3 baseline has stepped up from 3000 IOPS / 125 MiB/s to 12000 / 500: at 400 GiB
* (Db2, MariaDB, MySQL, PostgreSQL) or 200 GiB (Oracle), never on SQL Server.
* https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html#gp3-storage
*/
private static boolean gp3BaselineSteppedUp(DbInstance i) {
String engine = instanceEngine(i);
int threshold = engine.startsWith("sqlserver") ? Integer.MAX_VALUE : engine.startsWith("oracle") ? 200 : 400;
return i.getAllocatedStorage() >= threshold;
}
private String vpcSecurityGroupsXml(DbInstance i) {
List<String> groupIds = i.getVpcSecurityGroupIds();
if (groupIds.isEmpty()) {
@@ -817,7 +817,9 @@ public class RdsService implements Resettable, ResourceProvider {
DbInstanceSettings resolvedSettings = withEffectiveWindows(settings, null)
.withKmsKeyId(resolveKmsKeyArn(settings.kmsKeyId(), effectiveRegion));
if (isBlank(dbClusterIdentifier) && !isAuroraEngine(engineParam)) {
resolvedSettings = resolvedSettings.withIopsDefaultType();
resolvedSettings.validateStorageType();
resolvedSettings.validateStorageMembers(null);
} else {
resolvedSettings = resolvedSettings.withStorageType(null);
}
@@ -4144,6 +4146,7 @@ public class RdsService implements Resettable, ResourceProvider {
DbInstanceSettings effective = withEffectiveWindows(settings, instance);
if (isBlank(instance.getDbClusterIdentifier()) && !isAuroraEngine(engineName(instance))) {
effective.validateStorageType();
effective.validateStorageMembers(instance.getStorageType());
} else {
effective = effective.withStorageType(null);
}
@@ -26,6 +26,9 @@ public class DbInstance {
private String dbInstanceClass;
private int allocatedStorage;
private String storageType;
// Null until a request names them; Describe then reports the gp3 baseline for gp3 and omits them otherwise.
private Integer iops;
private Integer storageThroughput;
/** The RDS certificate authority for the instance; null on one stored before it was recorded. */
private String caCertificateIdentifier;
/** The license model the request named; null means the engine's default. */
@@ -149,6 +152,12 @@ public class DbInstance {
public String getStorageType() { return storageType != null ? storageType : DEFAULT_STORAGE_TYPE; }
public void setStorageType(String storageType) { this.storageType = storageType; }
public Integer getIops() { return iops; }
public void setIops(Integer iops) { this.iops = iops; }
public Integer getStorageThroughput() { return storageThroughput; }
public void setStorageThroughput(Integer storageThroughput) { this.storageThroughput = storageThroughput; }
public String getLicenseModel() { return licenseModel; }
public void setLicenseModel(String licenseModel) { this.licenseModel = licenseModel; }
public String getCaCertificateIdentifier() { return caCertificateIdentifier; }
@@ -5,6 +5,7 @@ import io.floci.aws.core.common.BackupWindows;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -29,7 +30,9 @@ public record DbInstanceSettings(Boolean storageEncrypted,
Integer maxAllocatedStorage,
String storageType,
String caCertificateIdentifier,
String licenseModel) {
String licenseModel,
Integer iops,
Integer storageThroughput) {
public DbInstanceSettings(Boolean storageEncrypted, String kmsKeyId, Integer backupRetentionPeriod,
String preferredBackupWindow, String preferredMaintenanceWindow,
Boolean copyTagsToSnapshot, Integer monitoringInterval, String monitoringRoleArn,
@@ -41,7 +44,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
preferredMaintenanceWindow, copyTagsToSnapshot, monitoringInterval, monitoringRoleArn,
performanceInsightsEnabled, performanceInsightsRetentionPeriod, engineLifecycleSupport,
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
caCertificateIdentifier, null);
caCertificateIdentifier, null, null, null);
}
public DbInstanceSettings(Boolean storageEncrypted, String kmsKeyId, Integer backupRetentionPeriod,
@@ -216,7 +219,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
performanceInsightsRetentionPeriod, engineLifecycleSupport,
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
caCertificateIdentifier, licenseModel);
caCertificateIdentifier, licenseModel, iops, storageThroughput);
}
public DbInstanceSettings withKmsKeyId(String resolvedKmsKeyId) {
@@ -225,7 +228,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
performanceInsightsRetentionPeriod, engineLifecycleSupport,
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
caCertificateIdentifier, licenseModel);
caCertificateIdentifier, licenseModel, iops, storageThroughput);
}
public DbInstanceSettings withStorageType(String resolvedStorageType) {
@@ -234,7 +237,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
performanceInsightsRetentionPeriod, engineLifecycleSupport,
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, resolvedStorageType,
caCertificateIdentifier, licenseModel);
caCertificateIdentifier, licenseModel, iops, storageThroughput);
}
/** The same settings with the CA certificate the service resolved. */
@@ -244,7 +247,12 @@ public record DbInstanceSettings(Boolean storageEncrypted,
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
performanceInsightsRetentionPeriod, engineLifecycleSupport,
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
resolvedCaCertificateIdentifier, licenseModel);
resolvedCaCertificateIdentifier, licenseModel, iops, storageThroughput);
}
/** Create's documented default: "io1, if the Iops parameter is specified". */
public DbInstanceSettings withIopsDefaultType() {
return storageType == null && iops != null && iops != 0 ? withStorageType("io1") : this;
}
public void validateStorageType() {
@@ -296,6 +304,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
instance.setEnabledCloudwatchLogsExports(
logExportChanges.applyTo(instance.getEnabledCloudwatchLogsExports()));
}
String previousType = instance.getStorageType();
if (storageType != null) {
instance.setStorageType(storageType);
}
@@ -308,5 +317,45 @@ public record DbInstanceSettings(Boolean storageEncrypted,
if (licenseModel != null && !licenseModel.isBlank()) {
instance.setLicenseModel(licenseModel);
}
if (iops != null) {
instance.setIops(iops);
}
if (storageThroughput != null) {
instance.setStorageThroughput(storageThroughput);
}
// One normalisation after the merge: a stored value the resulting type doesn't carry is dropped, and an
// Iops carried over from the other family (io <-> gp3) is dropped unless this request set one, so
// Describe reports the baseline rather than a figure that belonged to the old type.
String resolved = instance.getStorageType();
if (!"gp3".equals(resolved)) {
instance.setStorageThroughput(null);
}
if (iopsFamily(resolved) == null || (iops == null && !Objects.equals(iopsFamily(previousType), iopsFamily(resolved)))) {
instance.setIops(null);
}
}
private static String iopsFamily(String type) {
return "gp3".equals(type) ? "gp3" : "io1".equals(type) || "io2".equals(type) ? "io" : null;
}
/**
* Refuses Iops or StorageThroughput on a storage type that doesn't carry it, as the Rust reference does
* (InvalidParameterCombination). Rust checks on Modify only; Floci checks Create too. {@code currentType} is the instance's type on Modify, null on Create.
*/
public void validateStorageMembers(String currentType) {
String resolved = storageType != null ? storageType : currentType;
if (resolved == null) {
return;
}
// Iops=0 is how a modify says "back to standard storage", so it is no Iops at all
if (iops != null && iops != 0 && iopsFamily(resolved) == null) {
throw new AwsException("InvalidParameterCombination",
"Iops can't be specified for storage type " + resolved + ".", 400);
}
if (storageThroughput != null && !"gp3".equals(resolved)) {
throw new AwsException("InvalidParameterCombination",
"StorageThroughput can't be specified for storage type " + resolved + ".", 400);
}
}
}
@@ -451,6 +451,36 @@ class RdsQueryHandlerTest {
assertFalse(body.contains("<member><DBInstanceIdentifier>"), "Did not expect <member> wrapping DBInstance");
}
@Test
void describeDbInstances_standardStorageReportsZeroThroughput() {
// The API refuses StorageType=standard, so only a stored record can carry it.
DbInstance instance = makeInstance("std");
instance.setStorageType("standard");
when(service.listDbInstances(null, null)).thenReturn(List.of(instance));
String body = (String) handler.handle("DescribeDBInstances", params()).getEntity();
assertTrue(body.contains("<StorageThroughput>0</StorageThroughput>"), body);
}
@Test
void describeDbInstances_oracleGp3BaselineStepsUpAt200GiB() {
// Floci cannot create an Oracle instance, so the Oracle threshold is reachable only from here.
// An upper-case identifier on a stored record must still read as SQL Server (always the lower tier).
for (int[] row : new int[][] {{200, 12000, 500}, {199, 3000, 125}, {500, 3000, 125}}) {
DbInstance instance = makeInstance("ora");
instance.setEngineIdentifier(row[0] == 500 ? "SQLSERVER-SE" : "oracle-ee");
instance.setStorageType("gp3");
instance.setAllocatedStorage(row[0]);
when(service.listDbInstances(null, null)).thenReturn(List.of(instance));
String body = (String) handler.handle("DescribeDBInstances", params()).getEntity();
assertTrue(body.contains("<Iops>" + row[1] + "</Iops>"), body);
assertTrue(body.contains("<StorageThroughput>" + row[2] + "</StorageThroughput>"), body);
}
}
@Test
void describeDbInstances_echoesPubliclyAccessible() {
// AWS returns the requested value; a hard-coded false read back as drift for any client
@@ -7,6 +7,7 @@ import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.List;
@@ -36,10 +37,14 @@ class RdsStorageTypeIntegrationTest {
}
private static RequestSpecification create(String id, String engine) {
return create(id, engine, "20");
}
private static RequestSpecification create(String id, String engine, String storage) {
return query("CreateDBInstance").formParam("DBInstanceIdentifier", id)
.formParam("Engine", engine).formParam("DBInstanceClass", "db.t3.micro")
.formParam("MasterUsername", "admin").formParam("MasterUserPassword", "password123")
.formParam("AllocatedStorage", "20");
.formParam("AllocatedStorage", storage);
}
private static String type(Response response, String action) {
@@ -74,6 +79,7 @@ class RdsStorageTypeIntegrationTest {
assertEquals(200, read.statusCode());
assertEquals(storageType, read.xmlPath().getString(path + "StorageType"));
assertTrue(read.xmlPath().getList(path + "Iops").isEmpty());
assertEquals("0", read.xmlPath().getString(path + "StorageThroughput"));
}
} finally {
delete(createdId);
@@ -96,6 +102,140 @@ class RdsStorageTypeIntegrationTest {
}
}
private static List<String> described(String id, String field) {
return query("DescribeDBInstances").formParam("DBInstanceIdentifier", id).post("/").xmlPath().getList(
"DescribeDBInstancesResponse.DescribeDBInstancesResult.DBInstances.DBInstance." + field);
}
@Test
void iopsAndStorageThroughputAreStoredAndTheGp3BaselineFillsOmissions() {
String gp2 = "storage-iops-gp2";
String gp3 = "storage-iops-gp3";
String io1 = "storage-iops-io1";
try {
create(gp2).formParam("StorageType", "gp2").post("/").then().statusCode(200);
create(gp3).formParam("StorageType", "gp3").post("/").then().statusCode(200);
create(io1, "postgres", "100").formParam("StorageType", "io1").formParam("Iops", "2000").post("/").then().statusCode(200);
assertAll(() -> assertTrue(described(gp2, "Iops").isEmpty()),
() -> assertEquals(List.of("0"), described(gp2, "StorageThroughput")),
() -> assertEquals(List.of("3000"), described(gp3, "Iops")),
() -> assertEquals(List.of("125"), described(gp3, "StorageThroughput")),
() -> assertEquals(List.of("2000"), described(io1, "Iops")),
() -> assertEquals(List.of("0"), described(io1, "StorageThroughput")));
Response changed = query("ModifyDBInstance").formParam("DBInstanceIdentifier", gp3)
.formParam("Iops", "6000").formParam("StorageThroughput", "250").post("/");
assertEquals(200, changed.statusCode(), changed.asString());
query("ModifyDBInstance").formParam("DBInstanceIdentifier", gp3)
.formParam("BackupRetentionPeriod", "3").post("/").then().statusCode(200);
assertAll(() -> assertEquals(List.of("6000"), described(gp3, "Iops")),
() -> assertEquals(List.of("250"), described(gp3, "StorageThroughput")));
} finally {
delete(gp2);
delete(gp3);
delete(io1);
}
}
@ParameterizedTest
@CsvSource({"mysql,500,12000,500", "mysql,20,3000,125", "mysql,399,3000,125", "mysql,400,12000,500", "sqlserver-se,500,3000,125"})
void gp3BaselineDependsOnEngineAndSize(String engine, String storage, String iops, String throughput) {
String id = "storage-baseline-" + engine;
try {
Response created = query("CreateDBInstance").formParam("DBInstanceIdentifier", id)
.formParam("Engine", engine).formParam("DBInstanceClass", "db.t3.micro")
.formParam("MasterUsername", "admin").formParam("MasterUserPassword", "password123")
.formParam("AllocatedStorage", storage).formParam("StorageType", "gp3").post("/");
assertEquals(200, created.statusCode(), created.asString());
assertAll(() -> assertEquals(List.of(iops), described(id, "Iops")),
() -> assertEquals(List.of(throughput), described(id, "StorageThroughput")));
} finally {
delete(id);
}
}
@Test
void iopsAreOmittedOnceTheTypeStopsCarryingThem() {
String id = "storage-iops-to-gp2";
try {
create(id).formParam("StorageType", "gp3").formParam("Iops", "6000")
.formParam("StorageThroughput", "250").post("/").then().statusCode(200);
query("ModifyDBInstance").formParam("DBInstanceIdentifier", id).formParam("StorageType", "gp2")
.post("/").then().statusCode(200);
assertAll(() -> assertTrue(described(id, "Iops").isEmpty()),
() -> assertEquals(List.of("0"), described(id, "StorageThroughput")));
query("ModifyDBInstance").formParam("DBInstanceIdentifier", id).formParam("StorageType", "gp3")
.post("/").then().statusCode(200);
assertAll(() -> assertEquals(List.of("3000"), described(id, "Iops")),
() -> assertEquals(List.of("125"), described(id, "StorageThroughput")));
} finally {
delete(id);
}
}
@Test
void anIopsFigureFromIo1DoesNotSurviveASwitchToGp3() {
String id = "storage-io1-to-gp3";
try {
create(id, "postgres", "100").formParam("StorageType", "io1").formParam("Iops", "2000").post("/").then().statusCode(200);
query("ModifyDBInstance").formParam("DBInstanceIdentifier", id).formParam("StorageType", "gp3")
.post("/").then().statusCode(200);
assertEquals(List.of("3000"), described(id, "Iops"));
} finally {
delete(id);
}
}
@Test
void iopsAndThroughputAreRefusedOnATypeThatDoesNotCarryThem() {
String id = "storage-refuse-members";
try {
create(id, "postgres", "100").formParam("StorageType", "io1").formParam("Iops", "2000").post("/").then().statusCode(200);
Response throughput = query("ModifyDBInstance").formParam("DBInstanceIdentifier", id)
.formParam("StorageThroughput", "250").post("/");
Response iops = query("ModifyDBInstance").formParam("DBInstanceIdentifier", id)
.formParam("StorageType", "gp2").formParam("Iops", "3000").post("/");
query("ModifyDBInstance").formParam("DBInstanceIdentifier", id).formParam("StorageType", "gp3")
.post("/").then().statusCode(200);
assertAll(() -> assertEquals(400, throughput.statusCode(), throughput.asString()),
() -> assertTrue(throughput.asString().contains("InvalidParameterCombination")),
() -> assertEquals(400, iops.statusCode(), iops.asString()),
() -> assertTrue(iops.asString().contains("InvalidParameterCombination")),
() -> assertEquals(List.of("125"), described(id, "StorageThroughput")));
} finally {
delete(id);
}
}
@Test
void iopsZeroMovesAnIo1InstanceToGp2() {
String id = "storage-io1-iops-zero";
try {
create(id, "postgres", "100").formParam("StorageType", "io1").formParam("Iops", "2000")
.post("/").then().statusCode(200);
Response changed = query("ModifyDBInstance").formParam("DBInstanceIdentifier", id)
.formParam("StorageType", "gp2").formParam("Iops", "0").post("/");
assertAll(() -> assertEquals(200, changed.statusCode(), changed.asString()),
() -> assertTrue(described(id, "Iops").isEmpty()),
() -> assertEquals(List.of("gp2"), described(id, "StorageType")));
} finally {
delete(id);
}
}
@Test
void createWithIopsAndNoTypeDefaultsToIo1() {
String id = "storage-iops-default-io1";
try {
Response created = create(id, "postgres", "100").formParam("Iops", "2000").post("/");
assertAll(() -> assertEquals(200, created.statusCode(), created.asString()),
() -> assertEquals(List.of("io1"), described(id, "StorageType")),
() -> assertEquals(List.of("2000"), described(id, "Iops")));
} finally {
delete(id);
}
}
@Test
void modifyChangesTheTypeAndOmissionKeepsIt() {
String id = "storage-type-modify";