fix(rds): accept SessionPinningFilters on non-MySQL DB proxies (#8606)

This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-11-16 17:10:52 -04:00
1 parent 5f77b841a2
commit bda82cc98d
3 files changed
+39 -12

No files matched your search

+5 -3
View File
@@ -395,9 +395,11 @@ services:
Proxy and target-group settings are persisted and round-trip through the RDS Query API and
CloudFormation. Pool sizing, borrow timeout, idle timeout, TLS, init-query, and session-pinning
settings are currently control-plane metadata; the TCP relay does not yet implement those data-plane
behaviors. `DefaultAuthScheme=IAM_AUTH` is supported for control-plane workflows, but a real-mode
proxy using that scheme cannot register a target until backend IAM authentication is implemented.
settings are currently control-plane metadata; the TCP relay does not yet implement those
data-plane behaviors. `SessionPinningFilters` is accepted and stored on every engine family; AWS
documents it as effective only for the MySQL engine family. `DefaultAuthScheme=IAM_AUTH` is
supported for control-plane workflows, but a real-mode proxy using that scheme cannot register a
target until backend IAM authentication is implemented.
Requests to `RegisterDBProxyTargets`, `DeregisterDBProxyTargets`, and
`DescribeDBProxyTargets` use the `default` target group when `TargetGroupName` is omitted,
matching the RDS API contract.
@@ -7583,7 +7583,7 @@ public class RdsService implements Resettable, ResourceProvider {
DbProxy proxy = getDbProxy(dbProxyName, effectiveRegion);
DbProxyTargetGroup targetGroup = getDefaultProxyTargetGroup(
dbProxyName, targetGroupName, effectiveRegion);
validatePoolConfiguration(proxy, maxConnectionsPercent, maxIdleConnectionsPercent,
validatePoolConfiguration(maxConnectionsPercent, maxIdleConnectionsPercent,
connectionBorrowTimeout, sessionPinningFilters);
DbProxyTargetGroup updatedTargetGroup = copyProxyTargetGroup(targetGroup);
if (maxConnectionsPercent != null) {
@@ -7634,7 +7634,7 @@ public class RdsService implements Resettable, ResourceProvider {
List<String> instanceIds = dbInstanceIdentifiers != null
? dbInstanceIdentifiers : List.of();
validateProxyTargetSelection(proxy, clusterIds, instanceIds, effectiveRegion);
validatePoolConfiguration(proxy, maxConnectionsPercent, maxIdleConnectionsPercent,
validatePoolConfiguration(maxConnectionsPercent, maxIdleConnectionsPercent,
connectionBorrowTimeout, sessionPinningFilters);
DbProxyTarget currentTarget = original.getTargets().isEmpty()
@@ -9707,12 +9707,12 @@ public class RdsService implements Resettable, ResourceProvider {
private void validatePoolConfiguration(Integer maxConnectionsPercent,
Integer maxIdleConnectionsPercent) {
validatePoolConfiguration(null, maxConnectionsPercent, maxIdleConnectionsPercent,
validatePoolConfiguration(maxConnectionsPercent, maxIdleConnectionsPercent,
null, null);
}
private void validatePoolConfiguration(
DbProxy proxy, Integer maxConnectionsPercent, Integer maxIdleConnectionsPercent,
Integer maxConnectionsPercent, Integer maxIdleConnectionsPercent,
Integer connectionBorrowTimeout, List<String> sessionPinningFilters) {
if (maxConnectionsPercent != null) {
validatePercent("MaxConnectionsPercent", maxConnectionsPercent, 1, 100);
@@ -9729,10 +9729,6 @@ public class RdsService implements Resettable, ResourceProvider {
validatePercent("ConnectionBorrowTimeout", connectionBorrowTimeout, 0, 300);
}
if (sessionPinningFilters != null && !sessionPinningFilters.isEmpty()) {
if (proxy == null || !"MYSQL".equals(proxy.getEngineFamily())) {
throw new AwsException("InvalidParameterValue",
"SessionPinningFilters are supported only for MYSQL DB proxies.", 400);
}
if (sessionPinningFilters.stream()
.anyMatch(filter -> !"EXCLUDE_VARIABLE_SETS".equals(filter))) {
throw new AwsException("InvalidParameterValue",
@@ -9369,6 +9369,35 @@ class RdsServiceTest {
assertEquals(1, retry.getTargets().size());
}
@Test
void postgresqlProxyAcceptsSessionPinningFilters() {
// AWS documents the filter as effective only on MySQL, not as rejected elsewhere.
when(config.services().rds().mock()).thenReturn(true);
rdsService.createDbCluster("cluster1", "aurora-postgresql", "16.3",
"admin", "secret", "app", false, null);
rdsService.createDbProxy("pg-proxy", "POSTGRESQL", true, false,
PROXY_ROLE_ARN, PROXY_SUBNET_IDS, List.of(), PROXY_AUTH, Map.of());
rdsService.configureDbProxyTargetGroup("pg-proxy", "default", 80, 40, 120, null,
List.of("EXCLUDE_VARIABLE_SETS"), "us-east-1");
assertEquals(List.of("EXCLUDE_VARIABLE_SETS"), rdsService
.describeDbProxyTargetGroups("pg-proxy").iterator().next()
.getSessionPinningFilters());
DbProxyTargetGroup reconciled = rdsService.reconcileDbProxyTargetGroup(
"pg-proxy", "default", List.of("cluster1"), List.of(),
80, 40, 120, null, List.of("EXCLUDE_VARIABLE_SETS"), "us-east-1");
assertEquals(List.of("EXCLUDE_VARIABLE_SETS"), reconciled.getSessionPinningFilters());
AwsException invalid = assertThrows(AwsException.class, () ->
rdsService.configureDbProxyTargetGroup("pg-proxy", "default", 80, 40, 120,
null, List.of("INCLUDE_ALL"), "us-east-1"));
assertEquals("InvalidParameterValue", invalid.getErrorCode());
assertEquals(List.of("EXCLUDE_VARIABLE_SETS"), rdsService
.describeDbProxyTargetGroups("pg-proxy").iterator().next()
.getSessionPinningFilters());
}
@Test
void targetGroupReconciliationValidatesBeforeMutation() {
when(config.services().rds().mock()).thenReturn(true);
@@ -9382,7 +9411,7 @@ class RdsServiceTest {
AwsException invalid = assertThrows(AwsException.class, () ->
rdsService.reconcileDbProxyTargetGroup(
"app-proxy", "default", List.of("cluster1"), List.of(),
80, 40, 120, null, List.of("EXCLUDE_VARIABLE_SETS"), "us-east-1"));
80, 40, 120, null, List.of("INCLUDE_ALL"), "us-east-1"));
assertEquals("InvalidParameterValue", invalid.getErrorCode());
DbProxyTargetGroup after = rdsService.describeDbProxyTargetGroups("app-proxy")