Simple wrapper around aws-sdk to make it easier to use.
/!\ This module use async/await syntax, this is why you must have node 7.6+.
Supported and tested : >= 12.x
| Version | Supported | Tested |
|---|---|---|
| 16.x | yes | yes |
| 14.x | yes | yes |
| 12.x | yes | yes |
BREAKING CHANGES since version 2.0
Now dynamo tools returns an object and not directly an array of items.
{
Items:[ { ....} , { ... } ],LastEvaluatedKey: {....}}$ npm install @voodoo.io/aws-utils --saveconstawsUtils=require('@voodoo.io/aws-utils').dynamo;constaws=require('aws-sdk');aws.config.update({region: 'eu-west-1'});constdynamoCli=newaws.DynamoDB.DocumentClient();constdynamoTools=newawsUtils(dynamoCli)constres=awaitdynamoTools.queryHashKey('myTable','key','value');constres=awaitdynamoTools.query('myTable',{'conditions': [{'key': 'value','operator': 'value','value': []/** or ''**/}]})constres=awaitdynamoTools.scan('myTable');constres=awaitdynamoTools.putItem('myTable',{'key': 'value'});constres=awaitdynamoTools.putItems('myTable',[{'key': 'value'}]);constres=awaitdynamoTools.putTransactionItems([{'key': 'value'}]);awaitdynamoTools.update('myTable',{'key': {'primaryKey': 'value','sortKey': 'value'},'add': {['column1']: 'value'},'set': {'column2': 'value'}});constres=awaitdynamoTools.deleteItem('myTable',{'key': 'value'});dynamoTable: table's namehashKeyName: hashkey's namehashKeyValue: hashkey's valueexclusiveStartKey: (optional) start search at a specific keylimit: (optional) don't return more items than the limit
dynamoTable: table's namecustomParams: object with the conditions of the query
dynamoTable: table's nameitem: item to insert
dynamoTable: table's nameitem: an array of items to insert
dynamoTable: table's namehashKeyName: (optional) hashkey's namehashKeyValue: (optional) hashkey's valueexclusiveStartKey: (optional) start search at a specific keylimit: (optional) don't return more items than the limit
If no hashkey is provided it returns the full table.
dynamoTable: table's nameparams: parameters with columns to update
dynamoTable: table's namekey: hashkey to delete
constawsUtils=require('@voodoo.io/aws-utils').secretManager;constaws=require('aws-sdk');aws.config.update({region: 'eu-west-1'});constcli=newaws.SecretsManager({});constsecretManagerTools=newawsUtils(cli);constres=awaitsecretManagerTools.getSecretValue('secret');secret: secret's id
constawsUtils=require('@voodoo.io/aws-utils').s3;constaws=require('aws-sdk');aws.config.update({region: 'eu-west-1'});constcli=newaws.S3();consts3Tools=newawsUtils(cli);constres=awaits3Tools.getObject('bucket','key');bucket: bucket's namekey: path to the ressource (/path/file.json)
constres=awaits3Tools.putJsonObject('bucket','key',{"key": "value"});bucket: bucket's namekey: path to the ressource (/path/file.json)item: json object to save on S3
constres=awaits3Tools.emptyS3Directory('bucket','dir/');bucket: bucket's namedir: directory to remove
$ npm testCoverage report can be found in coverage/.