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

aws_rds: DatabaseCluster is not accepting token in monitoringInterval after CDK 2.171.0 #33504

Closed
1 task
jani-flaaming-rebase opened this issue Feb 19, 2025 · 3 comments · Fixed by #33516
Closed
1 task
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@jani-flaaming-rebase
Copy link

jani-flaaming-rebase commented Feb 19, 2025

Describe the bug

This pull request (introduced in CDK 2.171.0) is adding validation to RDS DatabaseCluster Construct Monitoring Interval field: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseCluster.html#monitoringinterval
#32157

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.170.0

Expected Behavior

Token should be an acceptable value for monitoring interval

Current Behavior

Only number is accepted for monitoring interval field.

Error: 'monitoringInterval' must be one of 0, 1, 5, 10, 15, 30, or 60 seconds, got: ${Token[TOKEN.4704]} seconds.
at new DatabaseClusterNew (../node_modules/aws-cdk-lib/aws-rds/lib/cluster.js:1:8607)
at new DatabaseCluster (../node_modules/aws-cdk-lib/aws-rds/lib/cluster.js:5:4525)

Reproduction Steps

Create CfnParameter and try to use CfnParameter field in RDS DatabaseCluster construct

this.monitoringInterval = new CfnParameter(this, 'MonitoringInterval', {
type: 'String',
description:
'The interval, in seconds, between points when Amazon RDS collects enhanced monitoring metrics for the DB instance',
constraintDescription: 'Must be one of these: 1, 5, 10, 15, 30, or 60',
default: '60',
allowedValues: ['1', '5', '10', '15', '30', '60']
})
...
new DatabaseCluster(
...
monitoringInterval: Duration.seconds(this.monitoringInterval.valueAsString),
...
)

Possible Solution

Allow monitoringInterval to be a token or a number instead of only number.

Additional Information/Context

As a workaround, property override can be used to bypass this issue.

CDK CLI Version

2.179.0

Framework Version

No response

Node.js Version

22.13.1

OS

Ubuntu 24.04

Language

TypeScript

Language Version

TypeScript 5.7.3

Other information

@jani-flaaming-rebase jani-flaaming-rebase added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 19, 2025
@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Feb 19, 2025
@ashishdhingra ashishdhingra self-assigned this Feb 19, 2025
@ashishdhingra ashishdhingra added 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 Feb 19, 2025
@ashishdhingra
Copy link
Contributor

Looks like the validation was added in PR #32157 (commit 01f2dcd). Perhaps, the validation and places where monitoringInterval is used, should check for condition !Token.isUnresolved(props.monitoringInterval). The change should be tested by doing action CDK deployment.

@jani-flaaming-rebase Are you sure you are getting the mentioned error since using your code, we would get error Argument of type 'string' is not assignable to parameter of type 'number' since cdk.Duration.seconds() accepts a number? Could you please share self-container code for testing?

Thanks,
Ashish

@ashishdhingra ashishdhingra added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 19, 2025
@jani-flaaming-rebase
Copy link
Author

I agree that adding this condition to the validation should fix the issue.

I double-checked the scenario. I checked out the previous commit without the workaround and I got the described error message.

The mentioned CDK code is inside Service Catalog product.

    const mysqlClusterProduct = new CloudFormationProduct(this, 'MySqlClusterProduct', {
          ...
    })

Passing a String to Duration.seconds hasn't been an issue previously. We have previously used CDK version 2.158.0 without issues.

Is this information enough or do you need have other things to consider?

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 20, 2025
@ashishdhingra ashishdhingra removed their assignment Feb 20, 2025
mergify bot pushed a commit that referenced this issue Feb 21, 2025
…k with token (#33516)

### Issue # (if applicable)

Closes #33504.

### Reason for this change

`monitoringInterval` prop in `DatabaseClusterProps` should accept a token.

### Description of changes

Skip validations if `monitoringInterval` is a token.

### Describe any new or updated permissions being added

N/A

### Description of how you validated changes

Added a unit test.

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

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@mergify mergify bot closed this as completed in #33516 Feb 21, 2025
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants