fix(rds): accept the master usernames each engine really allows (#3730)

The 16 character cap was applied to every engine, but RDS accepts 63 on
PostgreSQL and 32 on MySQL, so an instance whose master username is longer
could not be created at all. The bound now comes from DatabaseEngine, using
the engine createDbInstance already resolves; the character rule and the
error message are unchanged.

Closes #3729
This commit is contained in:
Michal Schreiber authored and GitHub committed 2026-09-16 09:39:37 -04:00
1 parent f99e507916
commit f48bc2aa40
4 files changed
+74 -2

No files matched your search

@@ -611,7 +611,8 @@ public class RdsService implements Resettable, ResourceProvider {
int proxyPort = allocateProxyPort();
if (masterUsername == null || masterUsername.isBlank()) {
masterUsername = "root";
} else if (masterUsername.length() > 16 || !masterUsername.matches("^[a-zA-Z][a-zA-Z0-9_]*$")) {
} else if (masterUsername.length() > engine.maxMasterUsernameLength()
|| !masterUsername.matches("^[a-zA-Z][a-zA-Z0-9_]*$")) {
throw new AwsException("InvalidParameterValue",
"MasterUsername must begin with a letter and contain only alphanumeric characters or underscores.", 400);
}
@@ -12,4 +12,14 @@ public enum DatabaseEngine {
case MYSQL, MARIADB -> 3306;
};
}
// The API reference documents 16 characters for every engine, but RDS accepts longer
// master usernames on PostgreSQL and MySQL. These are the limits the service enforces.
public int maxMasterUsernameLength() {
return switch (this) {
case POSTGRES -> 63;
case MYSQL -> 32;
case MARIADB -> 16;
};
}
}