百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

aws-secretsmanager-jdbc

> 编程语言
开源

AWS Secrets Manager JDBC 库使 Java 开发人员可以使用存储在 AWS Secrets Manager 中的密钥轻松连接到 SQL 数据库。

195 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

AWS Secrets Manager JDBC 库使 Java 开发人员可以使用存储在 AWS Secrets Manager 中的密钥轻松连接到 SQL 数据库。

AWS Secrets Manager JDBC Library

The AWS Secrets Manager JDBC Library enables Java developers to easily connect to SQL databases using secrets stored in AWS Secrets Manager.

License

This library is licensed under the Apache 2.0 License.

Features

  • Provides wrappers to common JDBC drivers enabling simple database connectivity
  • Provides database connection pooling support through c3p0

Building from Source

After you've downloaded the code from GitHub, you can build it using Maven.

  • To disable GPG signing in the build, use this command: mvn clean install -Dgpg.skip=true
  • To build the default (non-shaded) JAR, use this command: mvn clean install
  • To build the shaded (uber) JAR with all dependencies included, use this command: mvn clean install -Pshade The shaded JAR will be generated in the target/ directory with the -shaded classifier, e.g.: target/aws-secretsmanager-jdbc-2.0.3-shaded.jar

Usage

The recommended way to use the SQL Connection Library is to consume it from Maven. The latest released version can be found at: https://mvnrepository.com/artifact/com.amazonaws.secretsmanager/aws-secretsmanager-jdbc

xml

    com.amazonaws.secretsmanager
    aws-secretsmanager-jdbc
    2.1.3

To use the latest build (pre-release), don't forget to enable the download of snapshot jars from Maven.

xml

  
    allow-snapshots
    true
    
      
        snapshots-repo
        https://aws.oss.sonatype.org/content/repositories/snapshots
        false
        true
      
    
  

Usage Example

We provide database drivers that intercept calls to real database drivers and replace secret IDs with actual login credentials. This prevents hard-coding database credentials into your application code.

The following is an example which uses the secret to resolve both the endpoint and the login credentials.

// Load the JDBC driver
Class.forName( "com.amazonaws.secretsmanager.sql.AWSSecretsManagerPostgreSQLDriver" ).newInstance();

// Retrieve the connection info from the secret using the secret ARN
String URL = "secretId";

// Populate the user property with the secret ARN to retrieve user and password from the secret
Properties info = new Properties( );
info.put( "user", "secretId" );

// Establish the connection
conn = DriverManager.getConnection(URL, info);

To specify a custom endpoint and port instead of resolving from the secret, use the jdbc-secretsmanager prefix with your database information.

// Options to resolve the connection information

// Set url to secret arn to resolve endpoint and port from secret
String URL = "secretId";

// Use jdbc-secretsmanager prefix to specify endpoint and port instead of resolving from secret
String URL = "jdbc-secretsmanager:postgresql://example.com:5432/database";

The secret should be in the correct JSON format. For more information, see the AWS Secrets Manager documentation. For example:

json
{
  "host": "",
  "username": "",
  "password": "",
  "dbname": "",
  "port": ""
}

We support a variety of drivers. For more information, see the AWS Secrets Manager JDBC documentation.

Credentials

This library uses the Default Credential Provider Chain. The following options exist to override some of the defaults:

  1. Set a PrivateLink DNS endpoint URL and a region in the secretsmanager.properties file:
drivers.vpcEndpointUrl= #The endpoint URL
drivers.vpcEndpointRegion= #The endpoint region
  1. Override the primary region by setting the 'AWS_SECRET_JDBC_REGION' environment variable to the preferred region, or via the secretsmanager.properties file:
drivers.region= #The region to use.
  1. Enable Post-Quantum TLS (PQTLS) by setting the following in the secretsmanager.properties file:
drivers.postQuantumTlsEnabled=true

For more information about Post-Quantum TLS in the AWS SDK, see the AWS SDK for Java documentation.

NOTE: PQ-TLS uses the AWS Common Runtime (CRT) which relies on system libraries and may not work as expected on macOS or Windows at this time (ref).

If this driver is running on EKS, the library could pick up the credentials of the node it is running on instead of the service account role (issue). To address this, add version 2 of software.amazon.awssdk:sts to your Gradle/Maven project file as a dependency.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaawsaws-secrets-managerjdbc-driversecret

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言