AWS Secrets Manager JDBC 库使 Java 开发人员可以使用存储在 AWS Secrets Manager 中的密钥轻松连接到 SQL 数据库。
AWS Secrets Manager JDBC 库使 Java 开发人员可以使用存储在 AWS Secrets Manager 中的密钥轻松连接到 SQL 数据库。
The AWS Secrets Manager JDBC Library enables Java developers to easily connect to SQL databases using secrets stored in AWS Secrets Manager.
This library is licensed under the Apache 2.0 License.
After you've downloaded the code from GitHub, you can build it using Maven.
mvn clean install -Dgpg.skip=truemvn clean installmvn 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.jarThe 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
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.
allow-snapshots
true
snapshots-repo
https://aws.oss.sonatype.org/content/repositories/snapshots
false
true
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:
{
"host": "",
"username": "",
"password": "",
"dbname": "",
"port": ""
}We support a variety of drivers. For more information, see the AWS Secrets Manager JDBC documentation.
This library uses the Default Credential Provider Chain. The following options exist to override some of the defaults:
drivers.vpcEndpointUrl= #The endpoint URL
drivers.vpcEndpointRegion= #The endpoint regiondrivers.region= #The region to use.drivers.postQuantumTlsEnabled=trueFor 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,或尚未同步最近议题。