Skip to content

(aws-rds): Unable to use CfnParameter as port #17948

@Lewenhaupt

Description

@Lewenhaupt

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

const dbPort = new CfnParameter(this, 'DBPort', {
  type: 'Number',
  default: 5432
})

const postgresDb = new rds.DatabaseInstance(this, 'PostgresDb', {
      port: dbPort.valueAsNumber,
})

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-rdsRelated to Amazon Relational DatabasebugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions