Can't get port from RDS DatabaseCluster Endpoint
See original GitHub issueDescribe the bug I can’t pass the RDS port from one stack to another.
I open a question on StackOverflow about it, but now I think it’s actually a bug.
To Reproduce
class DbStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: { vpc: ec2.Vpc }) {
super(scope, id);
const { vpc } = props;
const db = new DatabaseCluster(this, "Database", {
engine: rds.DatabaseClusterEngine.AuroraPostgresql,
engineVersion: "10.7",
masterUser: {
username: "admin",
},
defaultDatabaseName: "main",
instanceProps: {
instanceType: new ec2.InstanceType("r5.large"),
vpcSubnets: {
subnetType: ec2.SubnetType.Private,
},
vpc,
},
storageEncrypted: true,
parameterGroup: {
parameterGroupName: "default.aurora-postgresql10",
} as any,
});
console.log(db.clusterEndpoint);
console.log(db.clusterEndpoint.hostname);
console.log(db.clusterEndpoint.port);
console.log(db.clusterEndpoint.socketAddress);
}
}
The console output is:
Endpoint {
hostname: '${Token[Resource.Endpoint.Address.148]}',
port: -1.8881545897087827e+289,
socketAddress: '${Token[Resource.Endpoint.Address.148]}:{IndirectPort}' }
${Token[Resource.Endpoint.Address.148]}
-1.8881545897087827e+289
${Token[Resource.Endpoint.Address.148]}:{IndirectPort}
Expected behavior
I need a way to determine the port.
Version:
- OS: Linux
- Programming Language: Typescript
- CDK Version: 0.33.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:17 (11 by maintainers)
Top Results From Across the Web
class DatabaseCluster (construct) · AWS CDK
Create a clustered database with a given number of instances. Example. declare const vpc: ec2.Vpc; const cluster = new rds ...
Read more >CreateDBCluster - Amazon Relational Database Service
The port number on which the instances in the DB cluster accept connections. RDS for MySQL and Aurora MySQL. Default: 3306. Valid values:...
Read more >@aws-cdk/aws-rds - npm
DatabaseCluster (this, 'Database', { engine: rds. ... RDS databases have a default port, so you don't need to specify the port:.
Read more >Getting started with AWS RDS Aurora DB Clusters - SQLShack
We are going to keep all the default values for the network configuration of this AWS RDS Aurora Cluster. The default database port...
Read more >What the difference between rds.DatabaseInstance and rds ...
public readonly dbCluster: rds.DatabaseCluster | rds.DatabaseInstance; constructor(scope: Construct, id: string, props?: StackProps) { ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@balupraveendatty maybe you’re missing a call to
Token.asString()
somewhere where you’re passing theport
directly as a number, where a string is expected? For example, this works for me:Produces:
The problem is still present on 1.45.0 - I get port number
-1.8881545897087736e+289
instead of3306
. Looks like overflow.