diff --git a/.github/workflows/run-integration-tests-codebuild.yml b/.github/workflows/run-integration-tests-codebuild.yml new file mode 100644 index 000000000..4245184ba --- /dev/null +++ b/.github/workflows/run-integration-tests-codebuild.yml @@ -0,0 +1,76 @@ +name: Run Aurora Integration Tests CodeBuild + +on: + workflow_dispatch: + push: + branches: + - main + - workflow + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + aurora-integration-tests: + strategy: + matrix: + engine_version: ["lts"] + environment: ["pg_integ"] + runs-on: codebuild-jdbcWrapper-${{ github.run_id }}-${{ github.run_attempt }} + environment: ${{ matrix.environment }} + steps: + - name: 'Clone repository' + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: 'Set up JDK 8' + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 8 + - name: 'Configure AWS credentials' + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: 'Set up temp AWS credentials' + run: | + creds=($(aws sts get-session-token \ + --duration-seconds 21600 \ + --query 'Credentials.[AccessKeyId, SecretAccessKey, SessionToken]' \ + --output text \ + | xargs)); + echo "::add-mask::${creds[0]}" + echo "::add-mask::${creds[1]}" + echo "::add-mask::${creds[2]}" + echo "TEMP_AWS_ACCESS_KEY_ID=${creds[0]}" >> $GITHUB_ENV + echo "TEMP_AWS_SECRET_ACCESS_KEY=${creds[1]}" >> $GITHUB_ENV + echo "TEMP_AWS_SESSION_TOKEN=${creds[2]}" >> $GITHUB_ENV + - name: Run integration tests + run: | + ./gradlew --no-parallel --no-daemon test-all-aurora + env: + AURORA_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }} + AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + AWS_ACCESS_KEY_ID: ${{ env.TEMP_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ env.TEMP_AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ env.TEMP_AWS_SESSION_TOKEN }} + RDS_ENDPOINT: ${{ secrets.RDS_ENDPOINT }} + AURORA_MYSQL_DB_ENGINE_VERSION: ${{ matrix.engine_version }} + AURORA_PG_ENGINE_VERSION: ${{ matrix.engine_version }} + - name: 'Archive junit results ${{ matrix.engine_version }}' + if: always() + uses: actions/upload-artifact@v4 + with: + name: junit-report-${{ matrix.engine_version }} + path: ./wrapper/build/test-results + retention-days: 5 + - name: 'Archive html summary report ${{ matrix.engine_version }}' + if: always() + uses: actions/upload-artifact@v4 + with: + name: html-summary-report-${{ matrix.engine_version }} + path: ./wrapper/build/report + retention-days: 5 diff --git a/examples/AWSDriverExample/build.gradle.kts b/examples/AWSDriverExample/build.gradle.kts index 1af1c303a..ea0f759e4 100644 --- a/examples/AWSDriverExample/build.gradle.kts +++ b/examples/AWSDriverExample/build.gradle.kts @@ -28,4 +28,5 @@ dependencies { implementation("io.opentelemetry:opentelemetry-exporter-otlp:1.36.0") implementation("com.amazonaws:aws-xray-recorder-sdk-core:2.15.0") implementation("org.jsoup:jsoup:1.17.2") + implementation("software.amazon.awssdk:ec2:2.25.2") } diff --git a/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java b/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java index df18c8461..dd00563ad 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java +++ b/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java @@ -22,9 +22,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; +import java.util.logging.Logger; public class SlidingExpirationCache { + private static final Logger LOGGER = + Logger.getLogger(SlidingExpirationCache.class.getName()); + protected final Map cache = new ConcurrentHashMap<>(); protected long cleanupIntervalNanos = TimeUnit.MINUTES.toNanos(10); protected final AtomicLong cleanupTimeNanos = new AtomicLong(System.nanoTime() + cleanupIntervalNanos); @@ -225,6 +229,7 @@ public CacheItem(final V item, final long expirationTimeNano) { * false. */ boolean shouldCleanup() { + LOGGER.finest("shouldCleanup: " + expirationTimeNano); if (shouldDisposeFunc != null) { return System.nanoTime() > expirationTimeNano && shouldDisposeFunc.shouldDispose(this.item); } diff --git a/wrapper/src/test/java/integration/TestEnvironmentInfo.java b/wrapper/src/test/java/integration/TestEnvironmentInfo.java index a2e37468e..ebb303ead 100644 --- a/wrapper/src/test/java/integration/TestEnvironmentInfo.java +++ b/wrapper/src/test/java/integration/TestEnvironmentInfo.java @@ -25,6 +25,7 @@ public class TestEnvironmentInfo { private String awsSessionToken; private String auroraRegion; + private String rdsEndpoint; private String auroraClusterName; private String iamUsername; @@ -79,6 +80,10 @@ public String getAuroraRegion() { return this.auroraRegion; } + public String getRdsEndpoint() { + return this.rdsEndpoint; + } + public String getAuroraClusterName() { return this.auroraClusterName; } @@ -95,6 +100,10 @@ public void setAuroraRegion(String auroraRegion) { this.auroraRegion = auroraRegion; } + public void setRdsEndpoint(String rdsEndpoint) { + this.rdsEndpoint = rdsEndpoint; + } + public void setAuroraClusterName(String auroraClusterName) { this.auroraClusterName = auroraClusterName; } diff --git a/wrapper/src/test/java/integration/container/TestDriverProvider.java b/wrapper/src/test/java/integration/container/TestDriverProvider.java index 72c09d807..148290cb0 100644 --- a/wrapper/src/test/java/integration/container/TestDriverProvider.java +++ b/wrapper/src/test/java/integration/container/TestDriverProvider.java @@ -146,7 +146,7 @@ public void beforeEach(ExtensionContext context) throws Exception { } if (testRequest.getDatabaseEngineDeployment() == DatabaseEngineDeployment.AURORA) { - AuroraTestUtility auroraUtil = new AuroraTestUtility(testInfo.getAuroraRegion()); + AuroraTestUtility auroraUtil = new AuroraTestUtility(testInfo.getAuroraRegion(), testInfo.getRdsEndpoint()); auroraUtil.waitUntilClusterHasRightState(testInfo.getAuroraClusterName()); boolean makeSureFirstInstanceWriter = @@ -161,7 +161,7 @@ public void beforeEach(ExtensionContext context) throws Exception { // Wait up to 5min long startTimeNano = System.nanoTime(); while ((instanceIDs.size() != testRequest.getNumOfInstances() - || instanceIDs.size() == 0 + || instanceIDs.isEmpty() || !auroraUtil.isDBInstanceWriter(instanceIDs.get(0))) && TimeUnit.NANOSECONDS.toMinutes(System.nanoTime() - startTimeNano) < 5) { diff --git a/wrapper/src/test/java/integration/container/tests/AdvancedPerformanceTest.java b/wrapper/src/test/java/integration/container/tests/AdvancedPerformanceTest.java index 2b4a1ba5b..f28b82650 100644 --- a/wrapper/src/test/java/integration/container/tests/AdvancedPerformanceTest.java +++ b/wrapper/src/test/java/integration/container/tests/AdvancedPerformanceTest.java @@ -26,6 +26,7 @@ import static software.amazon.jdbc.plugin.failover.FailoverConnectionPlugin.FAILOVER_TIMEOUT_MS; import integration.TestEnvironmentFeatures; +import integration.TestEnvironmentInfo; import integration.container.ConnectionStringHelper; import integration.container.TestDriverProvider; import integration.container.TestEnvironment; @@ -37,6 +38,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.net.InetAddress; +import java.net.URISyntaxException; import java.net.UnknownHostException; import java.sql.Connection; import java.sql.DriverManager; @@ -97,8 +99,16 @@ public class AdvancedPerformanceTest { private static final ConcurrentLinkedQueue perfDataList = new ConcurrentLinkedQueue<>(); - protected static final AuroraTestUtility auroraUtil = - new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion()); + protected static final AuroraTestUtility auroraUtil; + + static { + try { + final TestEnvironmentInfo info = TestEnvironment.getCurrent().getInfo(); + auroraUtil = new AuroraTestUtility(info.getAuroraRegion(), info.getRdsEndpoint()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } private static void doWritePerfDataToFile( String fileName, ConcurrentLinkedQueue dataList) throws IOException { diff --git a/wrapper/src/test/java/integration/container/tests/AuroraFailoverTest.java b/wrapper/src/test/java/integration/container/tests/AuroraFailoverTest.java index c4fb02739..520e9cb77 100644 --- a/wrapper/src/test/java/integration/container/tests/AuroraFailoverTest.java +++ b/wrapper/src/test/java/integration/container/tests/AuroraFailoverTest.java @@ -23,21 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.mysql.cj.conf.PropertyKey; -import integration.DatabaseEngine; -import integration.DriverHelper; -import integration.TestEnvironmentFeatures; -import integration.TestInstanceInfo; -import integration.container.ConnectionStringHelper; -import integration.container.ProxyHelper; -import integration.container.TestDriver; -import integration.container.TestDriverProvider; -import integration.container.TestEnvironment; -import integration.container.condition.DisableOnTestFeature; -import integration.container.condition.EnableOnNumOfInstances; -import integration.container.condition.EnableOnTestDriver; -import integration.container.condition.EnableOnTestFeature; -import integration.container.condition.MakeSureFirstInstanceWriter; -import integration.util.AuroraTestUtility; +import java.net.URISyntaxException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -53,6 +39,22 @@ import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; +import integration.DatabaseEngine; +import integration.DriverHelper; +import integration.TestEnvironmentFeatures; +import integration.TestEnvironmentInfo; +import integration.TestInstanceInfo; +import integration.container.ConnectionStringHelper; +import integration.container.ProxyHelper; +import integration.container.TestDriver; +import integration.container.TestDriverProvider; +import integration.container.TestEnvironment; +import integration.container.condition.DisableOnTestFeature; +import integration.container.condition.EnableOnNumOfInstances; +import integration.container.condition.EnableOnTestDriver; +import integration.container.condition.EnableOnTestFeature; +import integration.container.condition.MakeSureFirstInstanceWriter; +import integration.util.AuroraTestUtility; import software.amazon.jdbc.PropertyDefinition; import software.amazon.jdbc.ds.AwsWrapperDataSource; import software.amazon.jdbc.hostlistprovider.AuroraHostListProvider; @@ -73,8 +75,17 @@ public class AuroraFailoverTest { private static final Logger LOGGER = Logger.getLogger(AuroraFailoverTest.class.getName()); - protected static final AuroraTestUtility auroraUtil = - new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion()); + protected static final AuroraTestUtility auroraUtil; + + static { + try { + final TestEnvironmentInfo info = TestEnvironment.getCurrent().getInfo(); + auroraUtil = new AuroraTestUtility(info.getAuroraRegion(), info.getRdsEndpoint()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + protected static final int IS_VALID_TIMEOUT = 5; protected String currentWriter; diff --git a/wrapper/src/test/java/integration/container/tests/AutoscalingTests.java b/wrapper/src/test/java/integration/container/tests/AutoscalingTests.java index cf8e551b5..a535d7dbb 100644 --- a/wrapper/src/test/java/integration/container/tests/AutoscalingTests.java +++ b/wrapper/src/test/java/integration/container/tests/AutoscalingTests.java @@ -36,6 +36,7 @@ import integration.container.condition.EnableOnTestFeature; import integration.container.condition.MakeSureFirstInstanceWriter; import integration.util.AuroraTestUtility; +import java.net.URISyntaxException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -62,8 +63,16 @@ @EnableOnNumOfInstances(min = 5) @MakeSureFirstInstanceWriter public class AutoscalingTests { - protected static final AuroraTestUtility auroraUtil = - new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion()); + protected static final AuroraTestUtility auroraUtil; + + static { + try { + final TestEnvironmentInfo info = TestEnvironment.getCurrent().getInfo(); + auroraUtil = new AuroraTestUtility(info.getAuroraRegion(), info.getRdsEndpoint()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } protected static Properties getDefaultPropsNoPlugins() { final Properties props = ConnectionStringHelper.getDefaultProperties(); diff --git a/wrapper/src/test/java/integration/container/tests/AwsIamIntegrationTest.java b/wrapper/src/test/java/integration/container/tests/AwsIamIntegrationTest.java index a1975fc64..81df6fcb0 100644 --- a/wrapper/src/test/java/integration/container/tests/AwsIamIntegrationTest.java +++ b/wrapper/src/test/java/integration/container/tests/AwsIamIntegrationTest.java @@ -280,6 +280,7 @@ void test_TokenGenerators() { protected Properties initAwsIamProps(String user, String password) { final Properties props = ConnectionStringHelper.getDefaultProperties(); props.setProperty(PropertyDefinition.PLUGINS.name, "iam"); + props.setProperty(IamAuthConnectionPlugin.IAM_REGION.name, TestEnvironment.getCurrent().getInfo().getAuroraRegion()); props.setProperty(PropertyDefinition.USER.name, user); props.setProperty(PropertyDefinition.PASSWORD.name, password); DriverHelper.setTcpKeepAlive(TestEnvironment.getCurrent().getCurrentDriver(), props, false); diff --git a/wrapper/src/test/java/integration/container/tests/ReadWriteSplittingTests.java b/wrapper/src/test/java/integration/container/tests/ReadWriteSplittingTests.java index ff246863c..027b50ada 100644 --- a/wrapper/src/test/java/integration/container/tests/ReadWriteSplittingTests.java +++ b/wrapper/src/test/java/integration/container/tests/ReadWriteSplittingTests.java @@ -47,6 +47,7 @@ import integration.container.condition.EnableOnTestFeature; import integration.container.condition.MakeSureFirstInstanceWriter; import integration.util.AuroraTestUtility; +import java.net.URISyntaxException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -86,8 +87,17 @@ @MakeSureFirstInstanceWriter public class ReadWriteSplittingTests { - protected static final AuroraTestUtility auroraUtil = - new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion()); + protected static final AuroraTestUtility auroraUtil; + + static { + try { + final TestEnvironmentInfo info = TestEnvironment.getCurrent().getInfo(); + auroraUtil = new AuroraTestUtility(info.getAuroraRegion(), info.getRdsEndpoint()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + private static final Logger LOGGER = Logger.getLogger(ReadWriteSplittingTests.class.getName()); protected static Properties getProxiedPropsWithFailover() { diff --git a/wrapper/src/test/java/integration/host/TestEnvironment.java b/wrapper/src/test/java/integration/host/TestEnvironment.java index aa78141bd..157d2703c 100644 --- a/wrapper/src/test/java/integration/host/TestEnvironment.java +++ b/wrapper/src/test/java/integration/host/TestEnvironment.java @@ -35,6 +35,7 @@ import integration.util.AuroraTestUtility; import integration.util.ContainerHelper; import java.io.IOException; +import java.net.URISyntaxException; import java.net.UnknownHostException; import java.sql.SQLException; import java.util.ArrayList; @@ -82,6 +83,7 @@ public class TestEnvironment implements AutoCloseable { private boolean reuseAuroraDbCluster; private String auroraClusterName; // "cluster-mysql" private String auroraClusterDomain; // "XYZ.us-west-2.rds.amazonaws.com" + private String rdsEndpoint; // "https://rds-int.amazon.com" private String awsAccessKeyId; private String awsSecretAccessKey; @@ -103,7 +105,7 @@ private TestEnvironment(TestEnvironmentRequest request) { this.info.setRequest(request); } - public static TestEnvironment build(TestEnvironmentRequest request) throws IOException { + public static TestEnvironment build(TestEnvironmentRequest request) throws IOException, URISyntaxException { LOGGER.finest("Building test env: " + request.getEnvPreCreateIndex()); preCreateEnvironment(request.getEnvPreCreateIndex()); @@ -155,7 +157,7 @@ public static TestEnvironment build(TestEnvironmentRequest request) throws IOExc return env; } - private static TestEnvironment createAuroraEnvironment(TestEnvironmentRequest request) { + private static TestEnvironment createAuroraEnvironment(TestEnvironmentRequest request) throws URISyntaxException { EnvPreCreateInfo preCreateInfo = TestEnvironmentProvider.preCreateInfos.get(request.getEnvPreCreateIndex()); @@ -302,7 +304,7 @@ private static void createDatabaseContainers(TestEnvironment env) { } } - private static void createAuroraDbCluster(TestEnvironment env) { + private static void createAuroraDbCluster(TestEnvironment env) throws URISyntaxException { switch (env.info.getRequest().getDatabaseInstances()) { case SINGLE_INSTANCE: @@ -328,7 +330,7 @@ private static void createAuroraDbCluster(TestEnvironment env) { } } - private static void createAuroraDbCluster(TestEnvironment env, int numOfInstances) { + private static void createAuroraDbCluster(TestEnvironment env, int numOfInstances) throws URISyntaxException { env.info.setAuroraRegion( !StringUtils.isNullOrEmpty(config.auroraDbRegion) @@ -340,6 +342,8 @@ private static void createAuroraDbCluster(TestEnvironment env, int numOfInstance && Boolean.parseBoolean(config.reuseAuroraCluster); env.auroraClusterName = config.auroraClusterName; // "cluster-mysql" env.auroraClusterDomain = config.auroraClusterDomain; // "XYZ.us-west-2.rds.amazonaws.com" + env.rdsEndpoint = config.rdsEndpoint; // "XYZ.us-west-2.rds.amazonaws.com" + env.info.setRdsEndpoint(env.rdsEndpoint); if (StringUtils.isNullOrEmpty(env.auroraClusterDomain)) { throw new RuntimeException("Environment variable AURORA_CLUSTER_DOMAIN is required."); @@ -348,6 +352,7 @@ private static void createAuroraDbCluster(TestEnvironment env, int numOfInstance env.auroraUtil = new AuroraTestUtility( env.info.getAuroraRegion(), + env.rdsEndpoint, env.awsAccessKeyId, env.awsSecretAccessKey, env.awsSessionToken); diff --git a/wrapper/src/test/java/integration/host/TestEnvironmentConfiguration.java b/wrapper/src/test/java/integration/host/TestEnvironmentConfiguration.java index 582f4bdf9..7e0231ab2 100644 --- a/wrapper/src/test/java/integration/host/TestEnvironmentConfiguration.java +++ b/wrapper/src/test/java/integration/host/TestEnvironmentConfiguration.java @@ -78,6 +78,8 @@ public class TestEnvironmentConfiguration { public String auroraClusterName = System.getenv("AURORA_CLUSTER_NAME"); // "cluster-mysql" public String auroraClusterDomain = System.getenv("AURORA_CLUSTER_DOMAIN"); // "XYZ.us-west-2.rds.amazonaws.com" + public String rdsEndpoint = + System.getenv("RDS_ENDPOINT"); // "https://rds-int.amazon.com" // Expected values: "latest", "lts", or engine version, for example, "15.4" // If left as empty, will use LTS version diff --git a/wrapper/src/test/java/integration/util/AuroraTestUtility.java b/wrapper/src/test/java/integration/util/AuroraTestUtility.java index 8c9e38440..0bac03b7d 100644 --- a/wrapper/src/test/java/integration/util/AuroraTestUtility.java +++ b/wrapper/src/test/java/integration/util/AuroraTestUtility.java @@ -30,6 +30,8 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.InetAddress; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.UnknownHostException; import java.sql.Connection; @@ -61,9 +63,11 @@ import software.amazon.awssdk.core.waiters.WaiterResponse; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.ec2.Ec2Client; +import software.amazon.awssdk.services.ec2.Ec2ClientBuilder; import software.amazon.awssdk.services.ec2.model.DescribeSecurityGroupsResponse; import software.amazon.awssdk.services.ec2.model.Ec2Exception; import software.amazon.awssdk.services.rds.RdsClient; +import software.amazon.awssdk.services.rds.RdsClientBuilder; import software.amazon.awssdk.services.rds.model.CreateDbClusterRequest; import software.amazon.awssdk.services.rds.model.CreateDbInstanceRequest; import software.amazon.awssdk.services.rds.model.DBCluster; @@ -111,39 +115,17 @@ public class AuroraTestUtility { private static final String DUPLICATE_IP_ERROR_CODE = "InvalidPermission.Duplicate"; - /** - * Initializes an AmazonRDS & AmazonEC2 client. RDS client used to create/destroy clusters & instances. EC2 client - * used to add/remove IP from security group. - */ - public AuroraTestUtility() { - this(Region.US_EAST_1, DefaultCredentialsProvider.create()); - } - - /** - * Initializes an AmazonRDS & AmazonEC2 client. - * - * @param region define AWS Regions, refer to - * Regions, Availability Zones, and Local Zones - */ - public AuroraTestUtility(Region region) { - this(region, DefaultCredentialsProvider.create()); - } - - /** - * Initializes an AmazonRDS & AmazonEC2 client. - * - * @param region define AWS Regions, refer to - * Regions, Availability Zones, and Local Zones - */ - public AuroraTestUtility(String region) { - this(getRegionInternal(region), DefaultCredentialsProvider.create()); + public AuroraTestUtility(String region, String endpoint) throws URISyntaxException { + this(getRegionInternal(region), endpoint, DefaultCredentialsProvider.create()); } public AuroraTestUtility( - String region, String awsAccessKeyId, String awsSecretAccessKey, String awsSessionToken) { + String region, String rdsEndpoint, String awsAccessKeyId, String awsSecretAccessKey, String awsSessionToken) + throws URISyntaxException { this( getRegionInternal(region), + rdsEndpoint, StaticCredentialsProvider.create( StringUtils.isNullOrEmpty(awsSessionToken) ? AwsBasicCredentials.create(awsAccessKeyId, awsSecretAccessKey) @@ -154,17 +136,27 @@ public AuroraTestUtility( * Initializes an AmazonRDS & AmazonEC2 client. * * @param region define AWS Regions, refer to - * Regions, Availability Zones, and Local Zones + * Regions, + * Availability Zones, and Local Zones * @param credentialsProvider Specific AWS credential provider */ - public AuroraTestUtility(Region region, AwsCredentialsProvider credentialsProvider) { + public AuroraTestUtility(Region region, String rdsEndpoint, AwsCredentialsProvider credentialsProvider) + throws URISyntaxException { dbRegion = region; + final RdsClientBuilder rdsClientBuilder = RdsClient.builder() + .region(dbRegion) + .credentialsProvider(credentialsProvider); - rdsClient = - RdsClient.builder().region(dbRegion).credentialsProvider(credentialsProvider).build(); + if (!StringUtils.isNullOrEmpty(rdsEndpoint)) { + rdsClientBuilder.endpointOverride(new URI(rdsEndpoint)); + } - ec2Client = - Ec2Client.builder().region(dbRegion).credentialsProvider(credentialsProvider).build(); + rdsClient = rdsClientBuilder.build(); + ec2Client = Ec2Client.builder() + .region(dbRegion) + .credentialsProvider(credentialsProvider) + .build(); } protected static Region getRegionInternal(String rdsRegion) { @@ -602,8 +594,8 @@ public List getAuroraInstanceIds( ArrayList auroraInstances = new ArrayList<>(); try (final Connection conn = DriverManager.getConnection(connectionUrl, userName, password); - final Statement stmt = conn.createStatement(); - final ResultSet resultSet = stmt.executeQuery(retrieveTopologySql)) { + final Statement stmt = conn.createStatement(); + final ResultSet resultSet = stmt.executeQuery(retrieveTopologySql)) { while (resultSet.next()) { // Get Instance endpoints final String hostEndpoint = resultSet.getString("SERVER_ID");