-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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): Unable to use CfnParameter as port #17948
Comments
@ryparker you want to try and reproduce this one? |
Was able to reproduce this with the following code (using cdk import { App, Stack, CfnParameter } from '@aws-cdk/core';
import { DatabaseInstance, DatabaseInstanceEngine } from '@aws-cdk/aws-rds';
import { Vpc, SubnetType } from '@aws-cdk/aws-ec2';
const app = new App();
const stack = new Stack(app, 'sampleRds', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION
}
});
const dbPort = new CfnParameter(stack, 'DBPort', {
type: 'Number',
default: 5432
})
const vpc = Vpc.fromLookup(stack, 'Vpc', {
isDefault: true
})
const postgresDb = new DatabaseInstance(stack, 'PostgresDb', {
port: dbPort.valueAsNumber,
vpc,
engine: DatabaseInstanceEngine.POSTGRES,
vpcSubnets: {
subnetType: SubnetType.PUBLIC
}
}) CloudFormation output: PostgresDb29EB1611:
Type: AWS::RDS::DBInstance
Properties:
...
Port: "-1.888154589708827e+289" |
Thnx! |
From my point of view, this is caused by @skinny85 Are you working on it (because this issue is assigned to you)? If not, I can fix it and submit a PR. |
That would be awesome if you could work on this @jumic! |
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*
|
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*
What is the problem?
CfnParameters cannot be used for the port value of a DatabaseInstance in aws-rds. The value requires only a number and valueAsNumber on a CfnParameter doesn't produce a valid number on synthesis.
"Port": "-1.8881545897088186e+289"
instead of
"ToPort": { "Ref": "DBPort" }
(as it becomes for a security group)https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseInstance.html
Reproduction Steps
What did you expect to happen?
Expected that the generated cfn-template would have the port parameter as a reference to the cfn parameter
What actually happened?
The port parameter was set to a static value: -1.8881545897088186e+289
CDK CLI Version
2.0.0 (build 4b6ce31)
Framework Version
No response
Node.js Version
v16.9.1
OS
mac os
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: