-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RDS: support passing PreferredMaintenanceWindow to Cluster database instances #16954
Comments
Thanks for opening the issue @cpaton. This should be a relatively simple feature to implement - it means adding the Would you consider opening us a PR adding this feature? Here's our "Contributing guide": https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md. Thanks, |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
If anyone else is running into this, you can synchronize the DBInstance maintenance windows with the DBCluster window using this: function setInstanceMaintenanceWindows(cluster: rds.DatabaseCluster) {
const clusterNode = cluster.node.children.find(
(c) => c instanceof rds.CfnDBCluster
) as rds.CfnDBCluster;
cluster.node.children.forEach((c) => {
if (c instanceof rds.CfnDBInstance) {
const temp = c;
temp.preferredMaintenanceWindow = clusterNode.preferredMaintenanceWindow;
}
});
}
// setInstanceMaintenanceWindows(this.cluster); |
Can also use cdk.Aspects to set node property. cdk.Aspects.of(cluster).add({
visit: (node) => {
if (node instanceof rds.CfnDBInstance) {
node.addPropertyOverride(
"PreferredMaintenanceWindow",
"web:19:00-wed:19:30",
);
}
},
}); |
…luster database instances (#29033) ### Issue # (if applicable) Closes [#16954](#16954) ### Reason for this change Noticed that we were able to specify preferredMaintenanceWindow for a cluster, but unable to do so for the instances created under the cluster. Instead, AWS (semi-)randomly assigns a maintenance window ([doc](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance)) for the instances, which leads to things being out of sync b/w the cluster and its child instances There are some workarounds as mentioned in the issue above, but those are a little hacky (imo) and I figured adding the preferredMaintenanceWindow as an instance prop is a better long-term solution. Also, it might be hard for other developers to find the workarounds as they are only mentioned in the above issue and aren't available through normal channels (Stack overflow/official CDK docs) ### Description of changes Added optional preferredMaintenanceWindow field under `InstanceProps`, and passed that field in during the creation of the `CfnDBInstance`. Also added a quick unit test ### Description of how you validated changes Added a unit test, did not add integ tests. Ran `yarn build` and `yarn test` Callout: I was unable to run integration tests locally, kept getting errors with `yarn integ --directory packages/aws-cdk-lib/aws-rds` and `yarn integ-runner --directory packages/aws-cdk-lib/aws-rds` - `Error: Cannot find module './integ-runner.js'`, not sure if I'm missing something ### Checklist - [ x ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) No breaking changes *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Description
When creating a DatabaseCluster it should be possible to specify PreferredMaintenanceWindow property for the database instances as per https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-preferredmaintenancewindow
Use Case
Control maintenance window for database instances so maintenance is performed outside of production use hours e.g. minor version upgrades
Proposed Solution
Add preferredMaintenanceWindow property to InstanceProps when creating a DatabaseCluster. This value should be copied onto the underlying CfnDatabaseInstance object
Other information
No response
Acknowledge
The text was updated successfully, but these errors were encountered: