diff --git a/docs/services/rds.md b/docs/services/rds.md index 795cff8e94..a5545c01fe 100644 --- a/docs/services/rds.md +++ b/docs/services/rds.md @@ -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. diff --git a/src/main/java/io/floci/aws/services/rds/RdsService.java b/src/main/java/io/floci/aws/services/rds/RdsService.java index e446b6f9bc..a9be26eada 100644 --- a/src/main/java/io/floci/aws/services/rds/RdsService.java +++ b/src/main/java/io/floci/aws/services/rds/RdsService.java @@ -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 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 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", diff --git a/src/test/java/io/floci/aws/services/rds/RdsServiceTest.java b/src/test/java/io/floci/aws/services/rds/RdsServiceTest.java index 0c0ee391b3..0c4fefec04 100644 --- a/src/test/java/io/floci/aws/services/rds/RdsServiceTest.java +++ b/src/test/java/io/floci/aws/services/rds/RdsServiceTest.java @@ -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")