From e9652b54f09ec370b9c67d9a2f9b8aa4f5881b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paw=C5=82aszek?= Date: Tue, 14 Dec 2021 22:40:02 +0100 Subject: [PATCH 1/3] Externalized AWS --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index d553d39..85e2328 100644 --- a/index.js +++ b/index.js @@ -567,7 +567,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 From 2076e0608d8f086259bf5478adf0d5d579c36bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paw=C5=82aszek?= Date: Wed, 15 Dec 2021 08:39:17 +0100 Subject: [PATCH 2/3] Added description of the update in README --- README.md | 27 +++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e1eb3a..ef88bbe 100644 --- a/README.md +++ b/README.md @@ -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. | | @@ -336,6 +337,32 @@ 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, + ... +}) +``` + +or mocking AWS for testing. + ## 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. diff --git a/package.json b/package.json index 67544d4..91ac20d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data-api-client", - "version": "1.2.0", + "version": "1.2.1", "description": "A lightweight wrapper that simplifies working with the Amazon Aurora Serverless Data API", "main": "index.js", "scripts": { From e3f41926f5e3f5d8db9e1037c51b5d3ee407c84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paw=C5=82aszek?= Date: Wed, 15 Dec 2021 08:40:57 +0100 Subject: [PATCH 3/3] Tailored the description of the update in README --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index ef88bbe..370ce09 100644 --- a/README.md +++ b/README.md @@ -361,8 +361,6 @@ const data = require('data-api-client')({ }) ``` -or mocking AWS for testing. - ## 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.