Skip to content

Commit 377078e

Browse files
authored
Merge branch 'main' into s3_account_2
2 parents 6690c62 + 9c82bca commit 377078e

4 files changed

Lines changed: 56 additions & 0 deletions

File tree

packages/aws-cdk-lib/aws-rds/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,3 +1204,23 @@ The `vpc` parameter is optional.
12041204
If not provided, the cluster will be created in the default VPC of the account and region.
12051205
As this VPC is not deployed with AWS CDK, you can't configure the `vpcSubnets`, `subnetGroup` or `securityGroups` of the Aurora Serverless Cluster.
12061206
If you want to provide one of `vpcSubnets`, `subnetGroup` or `securityGroups` parameter, please provide a `vpc`.
1207+
1208+
### Preferred Maintenance Window
1209+
1210+
When creating an RDS cluster, it is possible to (optionally) specify a preferred maintenance window for the cluster as well as the instances under the cluster.
1211+
See [AWS docs](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance) for more information regarding maintenance windows.
1212+
1213+
The following code snippet shows an example of setting the cluster's maintenance window to 22:15-22:45 (UTC) on Saturdays, but setting the instances' maintenance window
1214+
to 23:15-23:45 on Sundays
1215+
1216+
```ts
1217+
declare const vpc: ec2.Vpc;
1218+
new rds.DatabaseCluster(this, 'DatabaseCluster', {
1219+
engine: rds.DatabaseClusterEngine.AURORA,
1220+
instanceProps: {
1221+
vpc: vpc,
1222+
preferredMaintenanceWindow: 'Sun:23:15-Sun:23:45',
1223+
},
1224+
preferredMaintenanceWindow: 'Sat:22:15-Sat:22:45',
1225+
});
1226+
```

packages/aws-cdk-lib/aws-rds/lib/cluster.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ function legacyCreateInstances(cluster: DatabaseClusterNew, props: DatabaseClust
14151415
autoMinorVersionUpgrade: instanceProps.autoMinorVersionUpgrade,
14161416
allowMajorVersionUpgrade: instanceProps.allowMajorVersionUpgrade,
14171417
deleteAutomatedBackups: instanceProps.deleteAutomatedBackups,
1418+
preferredMaintenanceWindow: instanceProps.preferredMaintenanceWindow,
14181419
});
14191420

14201421
// For instances that are part of a cluster:

packages/aws-cdk-lib/aws-rds/lib/props.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ export interface InstanceProps {
101101
* @default - `true` if `vpcSubnets` is `subnetType: SubnetType.PUBLIC`, `false` otherwise
102102
*/
103103
readonly publiclyAccessible?: boolean;
104+
105+
/**
106+
* A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC).
107+
*
108+
* Example: 'Sun:23:45-Mon:00:15'
109+
*
110+
* @default - 30-minute window selected at random from an 8-hour block of time for
111+
* each AWS Region, occurring on a random day of the week.
112+
* @see https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance
113+
*/
114+
readonly preferredMaintenanceWindow?: string;
104115
}
105116

106117
/**

packages/aws-cdk-lib/aws-rds/test/cluster.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,30 @@ describe('cluster new api', () => {
209209
],
210210
});
211211
});
212+
213+
test('preferredMaintenanceWindow provided in InstanceProps', () => {
214+
// GIVEN
215+
const stack = testStack();
216+
const vpc = new ec2.Vpc(stack, 'VPC');
217+
218+
const PREFERRED_MAINTENANCE_WINDOW: string = 'Sun:12:00-Sun:13:00';
219+
220+
// WHEN
221+
new DatabaseCluster(stack, 'Database', {
222+
engine: DatabaseClusterEngine.AURORA,
223+
instanceProps: {
224+
vpc: vpc,
225+
preferredMaintenanceWindow: PREFERRED_MAINTENANCE_WINDOW,
226+
},
227+
});
228+
229+
// THEN
230+
const template = Template.fromStack(stack);
231+
// maintenance window is set
232+
template.hasResourceProperties('AWS::RDS::DBInstance', Match.objectLike({
233+
PreferredMaintenanceWindow: PREFERRED_MAINTENANCE_WINDOW,
234+
}));
235+
});
212236
});
213237

214238
describe('migrate from instanceProps', () => {

0 commit comments

Comments
 (0)