Skip to content

Commit

Permalink
Merge branch 'main' into s3_account_2
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Mar 6, 2024
2 parents 6690c62 + 9c82bca commit 377078e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/aws-cdk-lib/aws-rds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1204,3 +1204,23 @@ The `vpc` parameter is optional.
If not provided, the cluster will be created in the default VPC of the account and region.
As this VPC is not deployed with AWS CDK, you can't configure the `vpcSubnets`, `subnetGroup` or `securityGroups` of the Aurora Serverless Cluster.
If you want to provide one of `vpcSubnets`, `subnetGroup` or `securityGroups` parameter, please provide a `vpc`.

### Preferred Maintenance Window

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.
See [AWS docs](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance) for more information regarding maintenance windows.

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
to 23:15-23:45 on Sundays

```ts
declare const vpc: ec2.Vpc;
new rds.DatabaseCluster(this, 'DatabaseCluster', {
engine: rds.DatabaseClusterEngine.AURORA,
instanceProps: {
vpc: vpc,
preferredMaintenanceWindow: 'Sun:23:15-Sun:23:45',
},
preferredMaintenanceWindow: 'Sat:22:15-Sat:22:45',
});
```
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ function legacyCreateInstances(cluster: DatabaseClusterNew, props: DatabaseClust
autoMinorVersionUpgrade: instanceProps.autoMinorVersionUpgrade,
allowMajorVersionUpgrade: instanceProps.allowMajorVersionUpgrade,
deleteAutomatedBackups: instanceProps.deleteAutomatedBackups,
preferredMaintenanceWindow: instanceProps.preferredMaintenanceWindow,
});

// For instances that are part of a cluster:
Expand Down
11 changes: 11 additions & 0 deletions packages/aws-cdk-lib/aws-rds/lib/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ export interface InstanceProps {
* @default - `true` if `vpcSubnets` is `subnetType: SubnetType.PUBLIC`, `false` otherwise
*/
readonly publiclyAccessible?: boolean;

/**
* A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC).
*
* Example: 'Sun:23:45-Mon:00:15'
*
* @default - 30-minute window selected at random from an 8-hour block of time for
* each AWS Region, occurring on a random day of the week.
* @see https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance
*/
readonly preferredMaintenanceWindow?: string;
}

/**
Expand Down
24 changes: 24 additions & 0 deletions packages/aws-cdk-lib/aws-rds/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,30 @@ describe('cluster new api', () => {
],
});
});

test('preferredMaintenanceWindow provided in InstanceProps', () => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

const PREFERRED_MAINTENANCE_WINDOW: string = 'Sun:12:00-Sun:13:00';

// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AURORA,
instanceProps: {
vpc: vpc,
preferredMaintenanceWindow: PREFERRED_MAINTENANCE_WINDOW,
},
});

// THEN
const template = Template.fromStack(stack);
// maintenance window is set
template.hasResourceProperties('AWS::RDS::DBInstance', Match.objectLike({
PreferredMaintenanceWindow: PREFERRED_MAINTENANCE_WINDOW,
}));
});
});

describe('migrate from instanceProps', () => {
Expand Down

0 comments on commit 377078e

Please sign in to comment.