Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/aws-cdk-lib/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,10 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
if (props.enableClusterLevelEnhancedMonitoring && !props.monitoringInterval) {
throw new ValidationError('`monitoringInterval` must be set when `enableClusterLevelEnhancedMonitoring` is true.', this);
}
if (props.monitoringInterval && [0, 1, 5, 10, 15, 30, 60].indexOf(props.monitoringInterval.toSeconds()) === -1) {
if (
props.monitoringInterval && !props.monitoringInterval.isUnresolved() &&
[0, 1, 5, 10, 15, 30, 60].indexOf(props.monitoringInterval.toSeconds()) === -1
) {
throw new ValidationError(`'monitoringInterval' must be one of 0, 1, 5, 10, 15, 30, or 60 seconds, got: ${props.monitoringInterval.toSeconds()} seconds.`, this);
}

Expand Down
25 changes: 25 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 @@ -3147,6 +3147,31 @@ describe('cluster', () => {
});
}).toThrow(`'monitoringInterval' must be one of 0, 1, 5, 10, 15, 30, or 60 seconds, got: ${monitoringInterval.toSeconds()} seconds.`);
});

test('accept token for monitoring interval', () => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');
const parameter = new cdk.CfnParameter(stack, 'MonitoringIntervalParameter', { type: 'Number' });

// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.auroraMysql({ version: AuroraMysqlEngineVersion.VER_3_07_1 }),
credentials: {
username: 'admin',
password: cdk.SecretValue.unsafePlainText('tooshort'),
},
vpc,
writer: ClusterInstance.serverlessV2('writer'),
monitoringInterval: cdk.Duration.seconds(parameter.valueAsNumber),
enableClusterLevelEnhancedMonitoring: true,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBCluster', {
MonitoringInterval: { Ref: 'MonitoringIntervalParameter' },
});
});
});

test('addRotationSingleUser()', () => {
Expand Down
Loading