Skip to content

Commit

Permalink
Merge pull request #112 from rpawlaszek/master
Browse files Browse the repository at this point in the history
Externalizing aws-sdk instance
  • Loading branch information
jeremydaly authored Apr 6, 2022
2 parents 5caf150 + e3f4192 commit dd30fd6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Below is a table containing all of the possible configuration options for the `d
| Property | Type | Description | Default |
| -------- | ---- | ----------- | ------- |
| AWS | `AWS` | A custom `aws-sdk` instance | |
| resourceArn | `string` | The ARN of your Aurora Serverless Cluster. This value is *required*, but can be overridden when querying. | |
| secretArn | `string` | The ARN of the secret associated with your database credentials. This is *required*, but can be overridden when querying. | |
| database | `string` | *Optional* default database to use with queries. Can be overridden when querying. | |
Expand Down Expand Up @@ -336,6 +337,30 @@ let result = await data.executeStatement({
)
```
## Custom AWS instance
`data-api-client` allows for introducing a custom `AWS` as a parameter. This parameter is optional. If not present - `data-api-client` will fall back to the default `AWS` instance that comes with the library.
```javascript
// Instantiate data-api-client with a custom AWS instance
const data = require('data-api-client')({
AWS: customAWS,
...
})
```
Custom AWS parameter allows to introduce, e.g. tracing Data API calls through X-Ray with:
```javascript
const AWSXRay = require('aws-xray-sdk')
const AWS = AWSXRay.captureAWS(require('aws-sdk'))

const data = require('data-api-client')({
AWS: AWS,
...
})
```
## Data API Limitations / Wonkiness
The first GA release of the Data API has *a lot* of promise, unfortunately, there are still quite a few things that make it a bit wonky and may require you to implement some workarounds. I've outlined some of my findings below.
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ const init = params => {

// TODO: Put this in a separate module for testing?
// Create an instance of RDSDataService
RDS: new AWS.RDSDataService(options)
RDS: params.AWS ? new params.AWS.RDSDataService(options) : new AWS.RDSDataService(options)

} // end config

Expand Down

0 comments on commit dd30fd6

Please sign in to comment.