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

feat(rds): add ability to specify PreferredMaintenanceWindow to RDS cluster database instances #29033

Merged
merged 7 commits into from
Mar 6, 2024
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 @@ -1371,6 +1371,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;
xazhao marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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';
xazhao marked this conversation as resolved.
Show resolved Hide resolved

// 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
Loading