Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ 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
- 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.2-shaded.jar`
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
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
<dependency>
<groupId>com.amazonaws.secretsmanager</groupId>
<artifactId>aws-secretsmanager-jdbc</artifactId>
Expand All @@ -35,7 +37,7 @@ The recommended way to use the SQL Connection Library is to consume it from Mave

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

``` xml
```xml
<profiles>
<profile>
<id>allow-snapshots</id>
Expand All @@ -53,13 +55,12 @@ To use the latest build (pre-release), don't forget to enable the download of sn
```

### 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();
Expand Down Expand Up @@ -88,30 +89,32 @@ 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](https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_secret_json_structure). For example:

```json
{
"host": "<host name>",
"username": "<username>",
"password": "<password>",
"dbname": "<database name>",
"port": "<port number>",
"port": "<port number>"
}
```

We support a variety of drivers. For more information, see the [AWS Secrets Manager JDBC documentation](https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_jdbc).


## Credentials

This library uses the [Default Credential Provider Chain](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials.html). 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:
1. Set a PrivateLink DNS endpoint URL and a region in the secretsmanager.properties file:

```text
drivers.vpcEndpointUrl= #The endpoint URL
drivers.vpcEndpointRegion= #The endpoint region
```

2) Override the primary region by setting the 'AWS_SECRET_JDBC_REGION' environment variable to the preferred region, or via the secretsmanager.properties file:
2. Override the primary region by setting the 'AWS_SECRET_JDBC_REGION' environment variable to the preferred region, or via the secretsmanager.properties file:

```text
drivers.region= #The region to use.
```
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<artifactId>aws-secretsmanager-jdbc</artifactId>
<packaging>jar</packaging>
<name>AWS Secrets Manager SQL Connection Library</name>
<version>2.0.2</version>
<version>2.0.3</version>
<description>The AWS Secrets Manager SQL Connection Library for Java enables Java developers to easily
connect to SQL databases using secrets stored in AWS Secrets Manager.
</description>
Expand Down