AWS Java SDK V2 and aws-secretsmanager-jdbc incompatibility?

212 views Asked by At

I have a Java application that uses some V2 dependencies to manage our AWS environment. Than, these are my other aws dependencies

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>secretsmanager</artifactId>
    <version>2.21.21</version>
</dependency>
<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>cloudfront</artifactId>
    <version>2.21.21</version>
</dependency>

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>s3</artifactId>
    <version>2.21.21</version>
    
</dependency>

To connect to our S3 buckets we build the S3 client in this way

S3ClientBuilder builder = S3Client.builder().region(Region.of(this.regionName)).forcePathStyle(true);
S3Client client = builder.build();

Now we need to use SecretsManager to manage the RDS DB credentials, so we added this dependency to our pom.xml

<dependency>
    <groupId>com.amazonaws.secretsmanager</groupId>
    <artifactId>aws-secretsmanager-jdbc</artifactId>
    <version>2.0.0</version>
</dependency>

and modified our application.yml to connect via SM.

spring:
 datasource:
    driver-class-name: com.amazonaws.secretsmanager.sql.AWSSecretsManagerMySQLDriver
    url: jdbc-secretsmanager:mysql://db_url:3306/db
    username: db/secret/test

The DB connection works well but we cannot build the S3Client anymore: the thread with it hangs indefinitely, no error, no exit, it just hang forever blocking all the application. As soon as we remove the aws-secretsmanager-jdbc dependency everything works well again. It looks like there is some incompatibility between the V2 sdk and the JDBC one. Any advice on how to use both? Thanks

0

There are 0 answers