aws-core-utils
Advanced tools
Comparing version 2.1.2 to 2.1.4
@@ -47,3 +47,3 @@ 'use strict'; | ||
* @param {Object|undefined} [context] - the context, which is just used for logging | ||
* @returns {Object} an cached or new AWS Kinesis instance created and cached for the specified or current region | ||
* @returns {AWS.Kinesis} a cached or new AWS Kinesis instance created and cached for the specified or current region | ||
*/ | ||
@@ -119,3 +119,4 @@ function setKinesis(kinesisOptions, context) { | ||
* @param {string} [region] - the optional AWS region to use - defaults to current AWS region if not specified | ||
* @returns {Object|undefined} the Kinesis instance cached for the given or current region (if any); otherwise returns undefined | ||
* @returns {AWS.Kinesis|undefined} the Kinesis instance cached for the given or current region (if any); otherwise | ||
* returns undefined | ||
*/ | ||
@@ -131,3 +132,3 @@ function getKinesis(region) { | ||
* @param {string} [region] - the optional AWS region to use - defaults to current AWS region if not specified | ||
* @returns {Object|undefined} the kinesis options used to construct the Kinesis instance cached for the given or | ||
* @returns {AWS.Kinesis|undefined} the kinesis options used to construct the Kinesis instance cached for the given or | ||
* current region (if any); otherwise returns undefined | ||
@@ -170,3 +171,3 @@ */ | ||
* @param {Object} context - the context to configure | ||
* @param {Object} [context.kinesis] - the current Kinesis instance cached on the context (if any) | ||
* @param {AWS.Kinesis} [context.kinesis] - the current Kinesis instance cached on the context (if any) | ||
* @param {Object|undefined} [kinesisOptions] - the optional Kinesis constructor options to use if no cached Kinesis | ||
@@ -173,0 +174,0 @@ * instance exists |
{ | ||
"name": "aws-core-utils", | ||
"version": "2.1.2", | ||
"description": "Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, etc.", | ||
"version": "2.1.4", | ||
"description": "Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc.", | ||
"author": "Byron du Preez", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
@@ -1,6 +0,5 @@ | ||
# aws-core-utils v2.1.2 | ||
# aws-core-utils v2.1.4 | ||
Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Kinesis, Lambdas, AWS errors, stream events, etc. | ||
Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc. | ||
Currently includes: | ||
@@ -11,2 +10,4 @@ - arns.js | ||
- Utilities for working with AWS errors. | ||
- dynamodb-doc-clients.js | ||
- Utilities for working with AWS.DynamoDB.DocumentClients and a module-scope cache of AWS.DynamoDB.DocumentClient instances by region for Lambda. | ||
- kinesis-utils.js | ||
@@ -67,2 +68,41 @@ - Utilities for working with AWS.Kinesis and a module-scope cache of AWS.Kinesis instances by region for Lambda. | ||
* To use the DynamoDB.DocumentClient utilities to cache and configure an AWS DynamoDB.DocumentClient instance per region | ||
```js | ||
const dynamoDBDocClients = require('aws-core-utils/dynamodb-doc-clients'); | ||
// Preamble to create a context and configure logging on the context | ||
const context = {}; | ||
const logging = require('logging-utils'); | ||
logging.configureDefaultLogging(context); | ||
// Define the DynamoDB.DocumentClient's constructor options that you want to use, e.g. | ||
const dynamoDBDocClientOptions = { | ||
// See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#constructor-property | ||
// and http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#constructor-property | ||
maxRetries: 0 | ||
// ... | ||
}; | ||
// To create and cache a new AWS DynamoDB.DocumentClient instance with the given DynamoDB.DocumentClient constructor | ||
// options for either the current region or the region specified in the given options OR reuse a previously cached | ||
// DynamoDB.DocumentClient instance (if any) that is compatible with the given options | ||
const dynamoDBDocClient = dynamoDBDocClients.setDynamoDBDocClient(dynamoDBDocClientOptions, context); | ||
// To configure a new AWS.DynamoDB.DocumentClient instance (or re-use a cached instance) on a context | ||
dynamoDBDocClients.configureDynamoDBDocClient(context, dynamoDBDocClientOptions); | ||
console.log(context.dynamoDBDocClient); | ||
// To get a previously set or configured AWS DynamoDB.DocumentClient instance for the current AWS region | ||
const dynamoDBDocClient1 = dynamoDBDocClients.getDynamoDBDocClient(); | ||
// ... or for a specified region | ||
const dynamoDBDocClient2 = dynamoDBDocClients.getDynamoDBDocClient('us-west-2'); | ||
// To get the original options that were used to construct a cached AWS DynamoDB.DocumentClient instance for the current or specified AWS region | ||
const optionsUsed1 = dynamoDBDocClients.getDynamoDBDocClientOptionsUsed(); | ||
const optionsUsed2 = dynamoDBDocClients.getDynamoDBDocClientOptionsUsed('us-west-1'); | ||
// To delete and remove a cached DynamoDB.DocumentClient instance from the cache | ||
const deleted = dynamoDBDocClients.deleteDynamoDBDocClient('eu-west-1'); | ||
``` | ||
* To use the Kinesis utilities to cache and configure an AWS Kinesis instance per region | ||
@@ -227,2 +267,13 @@ ```js | ||
### 2.1.4 | ||
- Updated JsDoc comments in `dynamodb-doc-clients` and `kinesis-utils` modules. | ||
### 2.1.3 | ||
- Added a new `dynamodb-doc-clients` module to enable creation and configuration of AWS DynamoDB.DocumentClient instances | ||
and caching of a DynamoDB.DocumentClient instance per region. Note that this new module is an almost exact replica of | ||
the `kinesis-utils` module, but for getting, setting and caching DynamoDB.DocumentClient instances instead of Kinesis | ||
instances. | ||
- Added `setDynamoDBDocClient`, `getDynamoDBDocClient`, `getDynamoDBDocClientOptionsUsed`, `deleteDynamoDBDocClient` | ||
and `configureDynamoDBDocClient` functions and unit tests for same. | ||
### 2.1.2 | ||
@@ -229,0 +280,0 @@ - Updated `core-functions` dependency to version 2.0.3 |
{ | ||
"name": "aws-core-utils-tests", | ||
"description": "Unit tests for aws-core-utils modules", | ||
"version": "2.1.2", | ||
"version": "2.1.4", | ||
"author": "Byron du Preez", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
@@ -46,5 +46,5 @@ 'use strict'; | ||
// "Clear" AWS_REGION to empty string | ||
console.log(`BEFORE reset process.env.AWS_REGION = (${process.env.AWS_REGION})`); | ||
//console.log(`BEFORE reset process.env.AWS_REGION = (${process.env.AWS_REGION})`); | ||
process.env.AWS_REGION = unset; | ||
console.log(`AFTER reset process.env.AWS_REGION = '${process.env.AWS_REGION}' (orig was ${origRegion})`); | ||
//console.log(`AFTER reset process.env.AWS_REGION = '${process.env.AWS_REGION}' (orig was ${origRegion})`); | ||
t.equal(process.env.AWS_REGION, unset, `process.env.AWS_REGION must be '${unset}' after reset`); | ||
@@ -66,5 +66,5 @@ | ||
// "Restore" original aws region | ||
console.log(`BEFORE restore process.env.AWS_REGION = '${process.env.AWS_REGION}' (orig was ${origRegion})`); | ||
//console.log(`BEFORE restore process.env.AWS_REGION = '${process.env.AWS_REGION}' (orig was ${origRegion})`); | ||
process.env.AWS_REGION = isBlank(origRegion) ? unset : origRegion; | ||
console.log(`AFTER restore process.env.AWS_REGION = '${process.env.AWS_REGION}' (orig was ${origRegion})`); | ||
//console.log(`AFTER restore process.env.AWS_REGION = '${process.env.AWS_REGION}' (orig was ${origRegion})`); | ||
// Check "restore" worked | ||
@@ -71,0 +71,0 @@ if (isBlank(origRegion)) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
241886
22
3621
342