Skip to content

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

Merged
mergify[bot] merged 3 commits intoaws:masterfrom
jumic:rds-port
Dec 15, 2021
Merged

fix(rds): unable to use tokens as port in DatabaseInstance#17995
mergify[bot] merged 3 commits intoaws:masterfrom
jumic:rds-port

Conversation

@jumic
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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.

? (props.performanceInsightRetention || PerformanceInsightRetention.DEFAULT)
: undefined,
port: props.port?.toString(),
port: props.port ? Tokenization.stringifyNumber(props.port) : undefined,
Copy link
Copy Markdown
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
Copy Markdown
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?

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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