Skip to content

aws-cdk-lib/aws-rds/DatabaseCluster: DatabaseCluster.instanceEndpoints does not return writer endpoints #29279

@steffenjambit

Description

@steffenjambit

Describe the bug

The DatabaseCluster.instanceEndpoints only returns the reader endpoints but not the writer endpoints, while DatabaseCluster.instanceIdentifiers returns identifiers for both.

Expected Behavior

According to the documentation I would expect both endpoints return the information for all instances:
Screenshot 2024-02-27 at 14 45 39

i.e. DatabaseCluster.instanceEndpoints should return writer and reader endpoints.

Current Behavior

DatabaseCluster.instanceEndpoints only returns the reader endpoints but not the writer endpoints

Reproduction Steps

const clusterProps:DatabaseClusterProps = {
     …,
     writer: ClusterInstance.serverlessV2('writer'),
     readers: [ClusterInstance.serverlessV2('reader')],
     …
};
databaseCluster = new DatabaseCluster(
    this,
   `${id}`,
     {
       ...clusterProps,
        credentials: Credentials.fromSecret(secret),
     },
);
databaseCluster.instanceEndpoints

Possible Solution

the writer endpoint should be added to instanceEndpoints here:

instanceIdentifiers.push(writer.instanceIdentifier);

Screenshot 2024-02-27 at 14 53 30

Additional Information/Context

No response

CDK CLI Version

2.130.0

Framework Version

No response

Node.js Version

v18.17.1

OS

Mac

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/mediumMedium work item – several days of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions