Skip to content
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

Closed
2 tasks
cpaton opened this issue Oct 13, 2021 · 5 comments · Fixed by #29033
Closed
2 tasks

RDS: support passing PreferredMaintenanceWindow to Cluster database instances #16954

cpaton opened this issue Oct 13, 2021 · 5 comments · Fixed by #29033
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database effort/small Small work item – less than a day of effort feature/coverage-gap Gaps in CloudFormation coverage by L2 constructs feature-request A feature should be added or improved. p2

Comments

@cpaton
Copy link

cpaton commented Oct 13, 2021

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

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@cpaton cpaton added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 13, 2021
@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Oct 13, 2021
@skinny85 skinny85 changed the title aws-rds: support passing PreferredMaintenanceWindow to database instances RDS: support passing PreferredMaintenanceWindow to Cluster database instances Oct 13, 2021
@skinny85
Copy link
Contributor

Thanks for opening the issue @cpaton. This should be a relatively simple feature to implement - it means adding the preferredMaintenanceWindow property to the InstanceProps interface, and then passing it here.

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,
Adam

@skinny85 skinny85 added feature/coverage-gap Gaps in CloudFormation coverage by L2 constructs p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Oct 13, 2021
@skinny85 skinny85 removed their assignment Oct 13, 2021
@github-actions
Copy link

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.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Oct 14, 2022
@ronocod
Copy link
Contributor

ronocod commented May 5, 2023

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);

@keisukekomeda
Copy link

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",
      );
    }
  },
});

@tim-finnigan tim-finnigan reopened this Feb 7, 2024
@tim-finnigan tim-finnigan removed the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Feb 7, 2024
@mergify mergify bot closed this as completed in #29033 Mar 6, 2024
mergify bot pushed a commit that referenced this issue Mar 6, 2024
…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*
Copy link

github-actions bot commented Mar 6, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database effort/small Small work item – less than a day of effort feature/coverage-gap Gaps in CloudFormation coverage by L2 constructs feature-request A feature should be added or improved. p2
Projects
None yet
5 participants