Skip to content

Conversation

@nickh8
Copy link
Contributor

@nickh8 nickh8 commented Sep 19, 2025

  • Update RDS Aurora deployment to use cluster endpoint instead of instance endpoint
  • Ensures deployments are resilient to instance failures and replacements

@nickh8 nickh8 marked this pull request as ready for review September 19, 2025 04:51
@nickh8 nickh8 requested a review from a team as a code owner September 19, 2025 04:51
@vigneshrajsb
Copy link
Contributor

hi @nickh8 !! thanks for contributing.. will test for backward compatibility and get back to you!! the changes look good but since aurora-restore script is used for both cluster and rds instance restore in its current use cases, the rds filter acted like a catch all and hence addl tests

@nickh8
Copy link
Contributor Author

nickh8 commented Oct 5, 2025

hi @nickh8 !! thanks for contributing.. will test for backward compatibility and get back to you!! the changes look good but since aurora-restore script is used for both cluster and rds instance restore in its current use cases, the rds filter acted like a catch all and hence addl tests

Thanks @vigneshrajsb! I made some changes to instead attempt to find the cluster endpoint if the instance is part of a cluster. If it is part of a cluster it will use the cluster endpoint. If the instance is not part of a cluster it should continue using the instance endpoint.

@vigneshrajsb vigneshrajsb requested a review from Copilot October 13, 2025 16:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Switch deployment logic to use the Aurora cluster endpoint instead of a single instance endpoint to improve resilience against instance failovers.

  • Extracts DB instance identifier from ARN instead of passing ARN as a filter.
  • Adds logic to look up the cluster and prefer the cluster (writer) endpoint over the instance endpoint.
  • Updates patch operation to occur only if a resolved databaseAddress is found.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 372 to 395
if (instanceArn) {
const instanceIdentifier = instanceArn.split(':').pop();
if (instanceIdentifier) {
const instances = await rds
.describeDBInstances({
DBInstanceIdentifier: instanceIdentifier,
})
.promise();
const database = instances.DBInstances?.[0];
if (database) {
databaseAddress = database.Endpoint?.Address;
if (database.DBClusterIdentifier) {
const clusters = await rds
.describeDBClusters({
DBClusterIdentifier: database.DBClusterIdentifier,
})
.promise();
const clusterEndpoint = clusters.DBClusters?.[0]?.Endpoint;
if (clusterEndpoint) {
databaseAddress = clusterEndpoint;
}
}
}
}
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This block is highly nested (five levels) which reduces readability. Consider flattening with early returns/guards or extracting helper functions (e.g., getInstanceIdentifierFromArn, fetchClusterEndpoint) to clarify the happy path and reduce indentation.

Copilot uses AI. Check for mistakes.
Combines improvements from both PRs:
- Pre-flight check for existing Aurora databases (PR GoodRxOSS#63)
- Cluster endpoint usage instead of instance endpoint (PR GoodRxOSS#50)

The helper function now uses cluster endpoints for better resilience
during instance failures and replacements.
@vigneshrajsb vigneshrajsb merged commit 0ce590c into GoodRxOSS:main Nov 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants