Skip to content

(aws-rds): when @aws-cdk/aws-rds:lowercaseDbIdentifier is true (which is the default in v2), tokens in the clusterIdentifier property get mutated and thus are not replaced during synthesis #18802

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

Closed
saltman424 opened this issue Feb 2, 2022 · 2 comments · Fixed by #20287
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 p1

Comments

@saltman424
Copy link
Contributor

saltman424 commented Feb 2, 2022

What is the problem?

The issue has to do with these lines (possibly more, but these are the only two that I saw):

? props.clusterIdentifier?.toLowerCase()

? props.instanceIdentifier?.toLowerCase()

The .toLowerCase messes up the tokens.

Reproduction Steps

new rds.DatabaseCluster(scope, 'DB', {
  clusterIdentifier: `my-${cdk.Lazy.string({ produce(): string { return 'prod' }})}-db-cluster`,
  engine: rds.DatabaseClusterEngine.auroraPostgres({ version: rds.AuroraPostgresEngineVersion.VER_13_4 }),
  instanceProps: { vpc }
})

What did you expect to happen?

Cluster identifier = my-prod-db-cluster

What actually happened?

Cluster identifier = my-${token[token.1234]}-db-cluster

CDK CLI Version

2.8.0

Framework Version

2.8.0

Node.js Version

16.13.1

OS

Microsoft Windows 10 Enterprise

Language

Typescript

Language Version

4.5.5

Other information

I am not sure how this should be handled, but some options are:

  • Simply ignore this feature when there is a token in the cluster identifier by adding && !cdk.Token.isUnresolved(clusterIdentifier) to the condition that checks if the feature flag is enabled
  • Print a warning when a token is in the cluster identifier, but still skip the toLowerCase method in that case
  • Convert everything besides the token(s) to lower case (I am not sure if there is a simple way to identify which parts of a string are tokens and which aren't)
@saltman424 saltman424 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 2, 2022
@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Feb 2, 2022
@ryparker ryparker added the p1 label Feb 2, 2022
@skinny85
Copy link
Contributor

skinny85 commented Feb 2, 2022

Thanks for opening the issue @saltman424!

I am not sure how this should be handled, but some options are:

  • Simply ignore this feature when there is a token in the cluster identifier by adding && !cdk.Token.isUnresolved(clusterIdentifier) to the condition that checks if the feature flag is enabled

I think this is the best solution - we can't really lowercase deploy-time values anyway.

Would you consider opening us a PR fixing this? Here's our "Contributing" guide: https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md.

Thanks,
Adam

@skinny85 skinny85 added 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 2, 2022
@skinny85 skinny85 removed their assignment Feb 2, 2022
@mergify mergify bot closed this as completed in #20287 May 11, 2022
mergify bot pushed a commit that referenced this issue May 11, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Fixes #18802

Pretty much does the suggested fix in the issue.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

wphilipw pushed a commit to wphilipw/aws-cdk that referenced this issue May 23, 2022
Fixes aws#18802

Pretty much does the suggested fix in the issue.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*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 bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants