Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit dc9cb4b

Browse files
committed
feat(DBCluster): add SecondsUntilAutoPause to ServerlessV2ScalingConfiguration
Adds support for the automatic pause/resume feature of Aurora Serverless v2. Also bumping the AWS Java SDK to 2.29.16.
1 parent c499488 commit dc9cb4b

File tree

19 files changed

+67
-54
lines changed

19 files changed

+67
-54
lines changed

aws-rds-cfn-common/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
<dependency>
2929
<groupId>software.amazon.awssdk</groupId>
3030
<artifactId>utils</artifactId>
31-
<version>2.28.14</version>
31+
<version>2.29.16</version>
3232
</dependency>
3333
<dependency>
3434
<groupId>software.amazon.awssdk</groupId>
3535
<artifactId>rds</artifactId>
36-
<version>2.28.14</version>
36+
<version>2.29.16</version>
3737
</dependency>
3838
<dependency>
3939
<groupId>software.amazon.cloudformation</groupId>

aws-rds-customdbengineversion/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>software.amazon.awssdk</groupId>
2525
<artifactId>rds</artifactId>
26-
<version>2.28.14</version>
26+
<version>2.29.16</version>
2727
</dependency>
2828
<dependency>
2929
<groupId>software.amazon.rds.common</groupId>
@@ -54,7 +54,7 @@
5454
<dependency>
5555
<groupId>software.amazon.awssdk</groupId>
5656
<artifactId>aws-query-protocol</artifactId>
57-
<version>2.20.138</version>
57+
<version>2.29.16</version>
5858
</dependency>
5959
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
6060
<dependency>

aws-rds-dbcluster/aws-rds-dbcluster.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@
338338
"MaxCapacity": {
339339
"description": "The maximum number of Aurora capacity units (ACUs) for a DB instance in an Aurora Serverless v2 cluster. You can specify ACU values in half-step increments, such as 40, 40.5, 41, and so on. The largest value that you can use is 128.",
340340
"type": "number"
341+
},
342+
"SecondsUntilAutoPause": {
343+
"type": "integer"
341344
}
342345
}
343346
},

aws-rds-dbcluster/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@
3030
<dependency>
3131
<groupId>software.amazon.awssdk</groupId>
3232
<artifactId>rds</artifactId>
33-
<version>2.28.14</version>
33+
<version>2.29.16</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>software.amazon.awssdk</groupId>
3737
<artifactId>ec2</artifactId>
38-
<version>2.28.14</version>
38+
<version>2.29.16</version>
3939
</dependency>
4040
<!-- https://mvnrepository.com/artifact/software.amazon.awssdk/aws-query-protocol -->
4141
<dependency>
4242
<groupId>software.amazon.awssdk</groupId>
4343
<artifactId>aws-query-protocol</artifactId>
44-
<version>2.28.14</version>
44+
<version>2.29.16</version>
4545
</dependency>
4646
<!-- https://mvnrepository.com/artifact/software.amazon.cloudformation/aws-cloudformation-rpdk-java-plugin -->
4747
<dependency>

aws-rds-dbcluster/src/main/java/software/amazon/rds/dbcluster/ModelAdapter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class ModelAdapter {
1414
private static final int DEFAULT_MAX_CAPACITY = 16;
1515
private static final int DEFAULT_MIN_CAPACITY = 2;
1616
private static final int DEFAULT_SECONDS_UNTIL_AUTO_PAUSE = 300;
17+
private static final int DEFAULT_SECONDS_UNTIL_AUTO_PAUSE_V2 = 300;
1718
private static final int DEFAULT_PORT = 3306;
1819

1920
private static final String ENGINE_AURORA = "aurora";
@@ -52,6 +53,13 @@ public static ResourceModel setDefaults(final ResourceModel resourceModel) {
5253
resourceModel.setScalingConfiguration(scalingConfiguration == null ? defaultScalingConfiguration : scalingConfiguration);
5354
}
5455

56+
final var serverlessV2ScalingConfiguration = resourceModel.getServerlessV2ScalingConfiguration();
57+
if (serverlessV2ScalingConfiguration != null && serverlessV2ScalingConfiguration.getMinCapacity() == 0) {
58+
if (serverlessV2ScalingConfiguration.getSecondsUntilAutoPause() == null) {
59+
serverlessV2ScalingConfiguration.setSecondsUntilAutoPause(DEFAULT_SECONDS_UNTIL_AUTO_PAUSE_V2);
60+
}
61+
}
62+
5563
final EngineMode engineMode = EngineMode.fromString(resourceModel.getEngineMode());
5664

5765
resourceModel.setPort(port != null ? port : getDefaultPortForEngine(resourceModel.getEngine(), engineMode));

aws-rds-dbcluster/src/main/java/software/amazon/rds/dbcluster/Translator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ static software.amazon.awssdk.services.rds.model.ServerlessV2ScalingConfiguratio
468468
return software.amazon.awssdk.services.rds.model.ServerlessV2ScalingConfiguration.builder()
469469
.maxCapacity(serverlessV2ScalingConfiguration.getMaxCapacity())
470470
.minCapacity(serverlessV2ScalingConfiguration.getMinCapacity())
471+
.secondsUntilAutoPause(serverlessV2ScalingConfiguration.getSecondsUntilAutoPause())
471472
.build();
472473
}
473474

aws-rds-dbcluster/src/main/java/software/amazon/rds/dbcluster/UpdateHandler.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,14 @@ protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
6868
"Resource is immutable"
6969
);
7070
}
71+
72+
if (!Objects.equals(request.getDesiredResourceState().getEngineLifecycleSupport(),
73+
request.getPreviousResourceState().getEngineLifecycleSupport()) &&
74+
!request.getRollback()) {
75+
throw new CfnInvalidRequestException("EngineLifecycleSupport cannot be modified.");
76+
}
77+
7178
return ProgressEvent.progress(desiredResourceState, callbackContext)
72-
.then(progress -> {
73-
try {
74-
if(!Objects.equals(request.getDesiredResourceState().getEngineLifecycleSupport(),
75-
request.getPreviousResourceState().getEngineLifecycleSupport()) &&
76-
!request.getRollback()) {
77-
throw new CfnInvalidRequestException("EngineLifecycleSupport cannot be modified.");
78-
}
79-
} catch (CfnInvalidRequestException e) {
80-
return Commons.handleException(progress, e, DEFAULT_DB_CLUSTER_ERROR_RULE_SET, requestLogger);
81-
}
82-
return progress;
83-
})
8479
.then(progress -> {
8580
if (shouldRemoveFromGlobalCluster(request.getPreviousResourceState(), request.getDesiredResourceState())) {
8681
progress.getCallbackContext().timestampOnce(RESOURCE_UPDATED_AT, Instant.now());

aws-rds-dbcluster/src/test/java/software/amazon/rds/dbcluster/UpdateHandlerTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.junit.jupiter.params.provider.Arguments;
2626
import org.junit.jupiter.params.provider.ArgumentsProvider;
2727
import org.junit.jupiter.params.provider.ArgumentsSource;
28+
import org.junit.jupiter.params.provider.CsvSource;
2829
import org.mockito.ArgumentCaptor;
2930
import org.mockito.Mock;
3031
import org.mockito.junit.jupiter.MockitoExtension;
@@ -824,8 +825,17 @@ void handleRequest_EngineVersionUpdateIfMismatch() {
824825
Assertions.assertThat(argument.getValue().allowMajorVersionUpgrade()).isTrue();
825826
}
826827

827-
@Test
828-
void handleRequest_ServerlessV2ScalingConfiguration_Success() {
828+
@ParameterizedTest
829+
@CsvSource({
830+
"1, , 3, , ", // modify minCapacity
831+
"1, , 0, 600, 600", // enable auto-pause with specific seconds until auto-pause
832+
"1, , 0, , 300", // enable auto-pause with default seconds until auto-pause
833+
"0, 600, 0, , 300" // reset seconds until auto-pause to default
834+
})
835+
void handleRequest_ServerlessV2ScalingConfiguration_Success(
836+
final double minCapacityBefore, final Integer secondsUntilAutoPauseBefore,
837+
final double minCapacityAfter, final Integer secondsUntilAutoPauseAfter,
838+
final Integer expectedSecondsUntilAutoPause) {
829839
when(rdsProxy.client().modifyDBCluster(any(ModifyDbClusterRequest.class)))
830840
.thenReturn(ModifyDbClusterResponse.builder().build());
831841
when(rdsProxy.client().removeTagsFromResource(any(RemoveTagsFromResourceRequest.class)))
@@ -841,13 +851,15 @@ void handleRequest_ServerlessV2ScalingConfiguration_Success() {
841851
transitions.add(DBCLUSTER_ACTIVE_NO_ROLE);
842852

843853
final ServerlessV2ScalingConfiguration previousServerlessV2ScalingConfiguration = ServerlessV2ScalingConfiguration.builder()
844-
.minCapacity(1.0)
854+
.minCapacity(minCapacityBefore)
845855
.maxCapacity(2.0)
856+
.secondsUntilAutoPause(secondsUntilAutoPauseBefore)
846857
.build();
847858

848859
final ServerlessV2ScalingConfiguration desiredServerlessV2ScalingConfiguration = ServerlessV2ScalingConfiguration.builder()
849-
.minCapacity(3.0)
860+
.minCapacity(minCapacityAfter)
850861
.maxCapacity(4.0)
862+
.secondsUntilAutoPause(secondsUntilAutoPauseAfter)
851863
.build();
852864

853865
test_handleRequest_base(
@@ -881,6 +893,7 @@ void handleRequest_ServerlessV2ScalingConfiguration_Success() {
881893
.isEqualTo(software.amazon.awssdk.services.rds.model.ServerlessV2ScalingConfiguration.builder()
882894
.maxCapacity(desiredServerlessV2ScalingConfiguration.getMaxCapacity())
883895
.minCapacity(desiredServerlessV2ScalingConfiguration.getMinCapacity())
896+
.secondsUntilAutoPause(expectedSecondsUntilAutoPause)
884897
.build());
885898
}
886899

@@ -997,7 +1010,7 @@ void handleRequest_ModifyDBCluster_HandleException(
9971010
}
9981011

9991012
@Test
1000-
public void handleRequest_EngineLifecycleSupportShouldFail() {
1013+
void handleRequest_EngineLifecycleSupportShouldFail() {
10011014
expectServiceInvocation = false;
10021015
test_handleRequest_base(
10031016
new CallbackContext(),

aws-rds-dbclusterendpoint/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>software.amazon.awssdk</groupId>
3232
<artifactId>rds</artifactId>
33-
<version>2.28.14</version>
33+
<version>2.29.16</version>
3434
</dependency>
3535
<!-- https://mvnrepository.com/artifact/software.amazon.cloudformation/aws-cloudformation-rpdk-java-plugin -->
3636
<dependency>
@@ -78,7 +78,7 @@
7878
<dependency>
7979
<groupId>software.amazon.awssdk</groupId>
8080
<artifactId>aws-query-protocol</artifactId>
81-
<version>2.20.138</version>
81+
<version>2.29.16</version>
8282
</dependency>
8383
<dependency>
8484
<groupId>software.amazon.rds.common</groupId>

aws-rds-dbclusterparametergroup/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>software.amazon.awssdk</groupId>
3232
<artifactId>rds</artifactId>
33-
<version>2.28.14</version>
33+
<version>2.29.16</version>
3434
</dependency>
3535
<!-- https://mvnrepository.com/artifact/software.amazon.cloudformation/aws-cloudformation-rpdk-java-plugin -->
3636
<dependency>
@@ -78,7 +78,7 @@
7878
<dependency>
7979
<groupId>software.amazon.awssdk</groupId>
8080
<artifactId>aws-query-protocol</artifactId>
81-
<version>2.20.138</version>
81+
<version>2.29.16</version>
8282
</dependency>
8383
<dependency>
8484
<groupId>software.amazon.rds.common</groupId>

0 commit comments

Comments
 (0)