feat: add RDS cluster parameter group actions (#838)

Implement the missing Aurora cluster parameter group APIs that the
Pulumi/Terraform AWS provider invokes via aws.rds.ClusterParameterGroup:

- CreateDBClusterParameterGroup
- DescribeDBClusterParameterGroups
- DeleteDBClusterParameterGroup
- ModifyDBClusterParameterGroup
- DescribeDBClusterParameters

Storage and handler logic mirrors the existing instance-level
parameter group implementation. Without these actions, any IaC stack
that defines an Aurora ClusterParameterGroup fails with
UnsupportedOperation and never reaches Aurora cluster creation.

Tests cover the new XML envelope shape, required-field validation,
service round-trip, duplicate rejection, and parameter modification.
This commit is contained in:
John Reynolds authored and GitHub committed 2026-05-14 20:39:30 -05:00
1 parent b63329f53e
commit 5cae86fc4d
5 files changed
+320

No files matched your search

@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.core.common.AwsNamespaces;
import io.github.hectorvent.floci.core.common.AwsQueryResponse;
import io.github.hectorvent.floci.core.common.XmlBuilder;
import io.github.hectorvent.floci.services.rds.model.DbCluster;
import io.github.hectorvent.floci.services.rds.model.DbClusterParameterGroup;
import io.github.hectorvent.floci.services.rds.model.DbEndpoint;
import io.github.hectorvent.floci.services.rds.model.DbInstance;
import io.github.hectorvent.floci.services.rds.model.DbInstanceStatus;
@@ -55,6 +56,11 @@ public class RdsQueryHandler {
case "DeleteDBParameterGroup" -> handleDeleteDbParameterGroup(params);
case "ModifyDBParameterGroup" -> handleModifyDbParameterGroup(params);
case "DescribeDBParameters" -> handleDescribeDbParameters(params);
case "CreateDBClusterParameterGroup" -> handleCreateDbClusterParameterGroup(params);
case "DescribeDBClusterParameterGroups" -> handleDescribeDbClusterParameterGroups(params);
case "DeleteDBClusterParameterGroup" -> handleDeleteDbClusterParameterGroup(params);
case "ModifyDBClusterParameterGroup" -> handleModifyDbClusterParameterGroup(params);
case "DescribeDBClusterParameters" -> handleDescribeDbClusterParameters(params);
default -> AwsQueryResponse.error("UnsupportedOperation",
"Operation " + action + " is not supported.", AwsNamespaces.RDS, 400);
};
@@ -344,6 +350,101 @@ public class RdsQueryHandler {
}
}
// ── Cluster Parameter Groups ──────────────────────────────────────────────
private Response handleCreateDbClusterParameterGroup(MultivaluedMap<String, String> params) {
String name = params.getFirst("DBClusterParameterGroupName");
String family = params.getFirst("DBParameterGroupFamily");
String description = params.getFirst("Description");
if (name == null || name.isBlank()) {
return AwsQueryResponse.error("InvalidParameterValue", "DBClusterParameterGroupName is required.", AwsNamespaces.RDS, 400);
}
try {
DbClusterParameterGroup group = service.createDbClusterParameterGroup(name, family, description);
String result = clusterParamGroupXml(group);
return Response.ok(AwsQueryResponse.envelope("CreateDBClusterParameterGroup", AwsNamespaces.RDS, result)).build();
} catch (AwsException e) {
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
}
}
private Response handleDescribeDbClusterParameterGroups(MultivaluedMap<String, String> params) {
String filterName = params.getFirst("DBClusterParameterGroupName");
try {
Collection<DbClusterParameterGroup> result = service.listDbClusterParameterGroups(filterName);
XmlBuilder xml = new XmlBuilder().start("DBClusterParameterGroups");
for (DbClusterParameterGroup g : result) {
xml.start("DBClusterParameterGroup").raw(clusterParamGroupInnerXml(g)).end("DBClusterParameterGroup");
}
xml.end("DBClusterParameterGroups").start("Marker").end("Marker");
return Response.ok(AwsQueryResponse.envelope("DescribeDBClusterParameterGroups", AwsNamespaces.RDS, xml.build())).build();
} catch (AwsException e) {
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
}
}
private Response handleDeleteDbClusterParameterGroup(MultivaluedMap<String, String> params) {
String name = params.getFirst("DBClusterParameterGroupName");
if (name == null || name.isBlank()) {
return AwsQueryResponse.error("InvalidParameterValue", "DBClusterParameterGroupName is required.", AwsNamespaces.RDS, 400);
}
try {
service.deleteDbClusterParameterGroup(name);
return Response.ok(AwsQueryResponse.envelopeNoResult("DeleteDBClusterParameterGroup", AwsNamespaces.RDS)).build();
} catch (AwsException e) {
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
}
}
private Response handleModifyDbClusterParameterGroup(MultivaluedMap<String, String> params) {
String name = params.getFirst("DBClusterParameterGroupName");
if (name == null || name.isBlank()) {
return AwsQueryResponse.error("InvalidParameterValue", "DBClusterParameterGroupName is required.", AwsNamespaces.RDS, 400);
}
Map<String, String> parameters = new HashMap<>();
for (int n = 1; ; n++) {
String paramName = params.getFirst("Parameters.member." + n + ".ParameterName");
if (paramName == null) {
break;
}
String paramValue = params.getFirst("Parameters.member." + n + ".ParameterValue");
if (paramValue != null) {
parameters.put(paramName, paramValue);
}
}
try {
DbClusterParameterGroup group = service.modifyDbClusterParameterGroup(name, parameters);
String result = new XmlBuilder()
.elem("DBClusterParameterGroupName", group.getDbClusterParameterGroupName())
.build();
return Response.ok(AwsQueryResponse.envelope("ModifyDBClusterParameterGroup", AwsNamespaces.RDS, result)).build();
} catch (AwsException e) {
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
}
}
private Response handleDescribeDbClusterParameters(MultivaluedMap<String, String> params) {
String name = params.getFirst("DBClusterParameterGroupName");
if (name == null || name.isBlank()) {
return AwsQueryResponse.error("InvalidParameterValue", "DBClusterParameterGroupName is required.", AwsNamespaces.RDS, 400);
}
try {
DbClusterParameterGroup group = service.getDbClusterParameterGroup(name);
XmlBuilder xml = new XmlBuilder().start("Parameters");
for (Map.Entry<String, String> entry : group.getParameters().entrySet()) {
xml.start("member")
.elem("ParameterName", entry.getKey())
.elem("ParameterValue", entry.getValue())
.elem("IsModifiable", true)
.end("member");
}
xml.end("Parameters").start("Marker").end("Marker");
return Response.ok(AwsQueryResponse.envelope("DescribeDBClusterParameters", AwsNamespaces.RDS, xml.build())).build();
} catch (AwsException e) {
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
}
}
// ── XML builders ──────────────────────────────────────────────────────────
private String dbInstanceXml(DbInstance i) {
@@ -472,6 +573,18 @@ public class RdsQueryHandler {
.build();
}
private String clusterParamGroupXml(DbClusterParameterGroup g) {
return new XmlBuilder().start("DBClusterParameterGroup").raw(clusterParamGroupInnerXml(g)).end("DBClusterParameterGroup").build();
}
private String clusterParamGroupInnerXml(DbClusterParameterGroup g) {
return new XmlBuilder()
.elem("DBClusterParameterGroupName", g.getDbClusterParameterGroupName())
.elem("DBParameterGroupFamily", g.getDbParameterGroupFamily())
.elem("Description", g.getDescription())
.build();
}
private String statusLabel(DbInstanceStatus status) {
return switch (status) {
case CREATING -> "creating";
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.rds.container.RdsContainerHandle;
import io.github.hectorvent.floci.services.rds.container.RdsContainerManager;
import io.github.hectorvent.floci.services.rds.model.DatabaseEngine;
import io.github.hectorvent.floci.services.rds.model.DbCluster;
import io.github.hectorvent.floci.services.rds.model.DbClusterParameterGroup;
import io.github.hectorvent.floci.services.rds.model.DbEndpoint;
import io.github.hectorvent.floci.services.rds.model.DbInstance;
import io.github.hectorvent.floci.services.rds.model.DbInstanceStatus;
@@ -38,6 +39,7 @@ public class RdsService {
private final StorageBackend<String, DbInstance> instances;
private final StorageBackend<String, DbCluster> clusters;
private final StorageBackend<String, DbParameterGroup> parameterGroups;
private final StorageBackend<String, DbClusterParameterGroup> clusterParameterGroups;
private final RdsContainerManager containerManager;
private final RdsProxyManager proxyManager;
private final RegionResolver regionResolver;
@@ -56,6 +58,7 @@ public class RdsService {
this.instances = new InMemoryStorage<>();
this.clusters = new InMemoryStorage<>();
this.parameterGroups = new InMemoryStorage<>();
this.clusterParameterGroups = new InMemoryStorage<>();
}
// ── DB Instances ──────────────────────────────────────────────────────────
@@ -369,6 +372,49 @@ public class RdsService {
return group;
}
// ── Cluster Parameter Groups ──────────────────────────────────────────────
public DbClusterParameterGroup createDbClusterParameterGroup(String name, String family, String description) {
if (clusterParameterGroups.get(name).isPresent()) {
throw new AwsException("DBParameterGroupAlreadyExists",
"DB cluster parameter group " + name + " already exists.", 400);
}
DbClusterParameterGroup group = new DbClusterParameterGroup(name, family, description);
clusterParameterGroups.put(name, group);
return group;
}
public DbClusterParameterGroup getDbClusterParameterGroup(String name) {
return clusterParameterGroups.get(name).orElseThrow(() ->
new AwsException("DBParameterGroupNotFound",
"DB cluster parameter group " + name + " not found.", 404));
}
public Collection<DbClusterParameterGroup> listDbClusterParameterGroups(String filterName) {
if (filterName != null && !filterName.isBlank()) {
return clusterParameterGroups.get(filterName).map(List::of).orElse(List.of());
}
return clusterParameterGroups.scan(k -> true);
}
public void deleteDbClusterParameterGroup(String name) {
if (clusterParameterGroups.get(name).isEmpty()) {
throw new AwsException("DBParameterGroupNotFound",
"DB cluster parameter group " + name + " not found.", 404);
}
clusterParameterGroups.delete(name);
}
public DbClusterParameterGroup modifyDbClusterParameterGroup(String name,
java.util.Map<String, String> parameters) {
DbClusterParameterGroup group = getDbClusterParameterGroup(name);
if (parameters != null) {
group.getParameters().putAll(parameters);
}
clusterParameterGroups.put(name, group);
return group;
}
// ── Password validation callbacks ─────────────────────────────────────────
public boolean validateDbPassword(String instanceId, String clientUser, String password) {
@@ -0,0 +1,36 @@
package io.github.hectorvent.floci.services.rds.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.HashMap;
import java.util.Map;
@RegisterForReflection
public class DbClusterParameterGroup {
private String dbClusterParameterGroupName;
private String dbParameterGroupFamily;
private String description;
private Map<String, String> parameters = new HashMap<>();
public DbClusterParameterGroup() {}
public DbClusterParameterGroup(String dbClusterParameterGroupName, String dbParameterGroupFamily,
String description) {
this.dbClusterParameterGroupName = dbClusterParameterGroupName;
this.dbParameterGroupFamily = dbParameterGroupFamily;
this.description = description;
}
public String getDbClusterParameterGroupName() { return dbClusterParameterGroupName; }
public void setDbClusterParameterGroupName(String dbClusterParameterGroupName) { this.dbClusterParameterGroupName = dbClusterParameterGroupName; }
public String getDbParameterGroupFamily() { return dbParameterGroupFamily; }
public void setDbParameterGroupFamily(String dbParameterGroupFamily) { this.dbParameterGroupFamily = dbParameterGroupFamily; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public Map<String, String> getParameters() { return parameters; }
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
}