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

fix(rds): unable to use tokens as port in DatabaseInstance #17995

Merged
merged 3 commits into from
Dec 15, 2021

Conversation

jumic
Copy link
Contributor

@jumic jumic commented Dec 13, 2021

In DatabaseInstance the port number can be specified using data type number.
If a token value (e.g. CloudFormation Parameter) was used here, the token was not resolved correctly.

The conversion of property port has been corrected by using method Tokenization.stringifyNumber().

Fixes #17948.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Dec 13, 2021

@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Dec 13, 2021
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @jumic! A few tiny comments first.

packages/@aws-cdk/aws-rds/test/instance.test.ts Outdated Show resolved Hide resolved
@@ -746,7 +746,7 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData
performanceInsightsRetentionPeriod: enablePerformanceInsights
? (props.performanceInsightRetention || PerformanceInsightRetention.DEFAULT)
: undefined,
port: props.port?.toString(),
port: props.port ? Tokenization.stringifyNumber(props.port) : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:

  1. I think you want the condition to be props.port === undefined, as 0 is falsy in JavaScript.
  2. I believe you can use Token.toString(props.port) instead - it's more of the idiomatic way to do it (Tokenization is more of an internal class).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Good catch. 0 is a valid port number. I changed it.
  2. Method Token.toString() doesn't accept an attribute. So I can't use it. Should I try something else? Or is Tokenization.stringifyNumber(props.port) the only way to handle it?

packages/@aws-cdk/aws-rds/test/instance.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/test/instance.test.ts Outdated Show resolved Hide resolved
@mergify mergify bot dismissed skinny85’s stale review December 14, 2021 17:39

Pull request has been modified.

@jumic jumic requested a review from skinny85 December 14, 2021 17:43
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the contribution @jumic!

@mergify
Copy link
Contributor

mergify bot commented Dec 14, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: af6d9d4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 0745193 into aws:master Dec 15, 2021
@mergify
Copy link
Contributor

mergify bot commented Dec 15, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
In `DatabaseInstance` the port number can be specified using data type number.
If a token value (e.g. CloudFormation Parameter) was used here, the token was not resolved correctly.

The conversion of property `port` has been corrected by using method `Tokenization.stringifyNumber()`.

Fixes aws#17948.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-rds): Unable to use CfnParameter as port
3 participants