Reputation: 3077
Please refer the following code which I am using to list log files available in RDS ( Mysql )
AWSCredentials credentials = new BasicAWSCredentials("XXX", "XXX");
AWSCredentialsProvider provider = new StaticCredentialsProvider(credentials);
AmazonRDS rdsClient = AmazonRDSClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("XXXX.us-west-2.rds.amazonaws.com:3306", "us-west-2"))
.withCredentials(provider)
.build();
DescribeDBLogFilesRequest request = new DescribeDBLogFilesRequest();
DescribeDBLogFilesResult response = rdsClient.describeDBLogFiles(request);
List<DescribeDBLogFilesDetails> listOfFiles = response.getDescribeDBLogFiles();
System.out.println(listOfFiles.toString());
System.out.println("Program done");
Here is my pom.xml dependencies :
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-rds -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-rds</artifactId>
<version>1.11.101</version>
</dependency>
I am facing exception when using the above code.
Upvotes: 3
Views: 6132
Reputation: 179374
The error is here:
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("XXXX.us-west-2.rds.amazonaws.com:3306", "us-west-2"))
You're trying to connect to your actual RDS instance with the SDK, and that isn't the correct approach. You need to connect to the RDS Query API Endpoint. These requests are sent through the service.
You should be able to simply use .withRegion()
, and not have to actually supply the endpoint URL, since the endpoint is the same for all RDS instances within a region, and the default regional URLs are coded into the SDK.
Upvotes: 3