Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@voodoo.io/aws-utils

Package Overview
Dependencies
Maintainers
6
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voodoo.io/aws-utils

AWS utils methods - using homemade retry system

  • 3.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
77
increased by20.31%
Maintainers
6
Weekly downloads
 
Created
Source

aws-utils

AWS utils with built-in retry system


npm version

Purpose

Simple wrapper around aws-sdk to make it easier to use.

Compatibility

/!\ This module use async/await syntax, this is why you must have node 7.6+.

Supported and tested : >= 12.x

VersionSupportedTested
16.xyesyes
14.xyesyes
12.xyesyes

BREAKING CHANGES since version 2.0

Now dynamo tools returns an object and not directly an array of items.

{
    Items:[ { ....} , { ... } ],
    LastEvaluatedKey: {....}
}

Installation

$ npm install @voodoo.io/aws-utils --save

Usage

Dynamo tools

Configure dynamo tools

const awsUtils = require('@voodoo.io/aws-utils').dynamo;

const aws = require('aws-sdk');
aws.config.update({region: 'eu-west-1'});
const dynamoCli = new aws.DynamoDB.DocumentClient();
const dynamoTools = new awsUtils(dynamoCli)

Query

const res = await dynamoTools.queryHashKey('myTable', 'key', 'value');
const res = await dynamoTools.query('myTable', { 'conditions': [{'key': 'value', 'operator': 'value', 'value': [] /** or ''**/}]})

Scan

const res = await dynamoTools.scan('myTable');

Put item

const res = await dynamoTools.putItem('myTable', {'key': 'value'});

Put items

const res = await dynamoTools.putItems('myTable', [{'key': 'value'}]);

Put transactional items

const res = await dynamoTools.putTransactionItems([{'key': 'value'}]);

Update item

await dynamoTools.update('myTable', {'key': {'primaryKey': 'value', 'sortKey': 'value'},'add': {['column1']: 'value'}, 'set': {'column2': 'value'}});

delete item

const res = await dynamoTools.deleteItem('myTable', {'key': 'value'});
queryHashKey(dynamoTable, hashKeyName, hashKeyValue, [exclusiveStartKey], [limit])
  • dynamoTable : table's name
  • hashKeyName : hashkey's name
  • hashKeyValue : hashkey's value
  • exclusiveStartKey : (optional) start search at a specific key
  • limit : (optional) don't return more items than the limit
query(dynamoTable, customParams)
  • dynamoTable : table's name
  • customParams : object with the conditions of the query
putItem(dynamoTable, item)
  • dynamoTable : table's name
  • item : item to insert
putItems(dynamoTable, items)
  • dynamoTable : table's name
  • item : an array of items to insert
scan(dynamoTable, [hashKeyName], [hashKeyValue], [exclusiveStartKey], [limit])
  • dynamoTable : table's name
  • hashKeyName : (optional) hashkey's name
  • hashKeyValue : (optional) hashkey's value
  • exclusiveStartKey : (optional) start search at a specific key
  • limit : (optional) don't return more items than the limit

If no hashkey is provided it returns the full table.

updateItem(dynamoTable, params)
  • dynamoTable : table's name
  • params : parameters with columns to update
deleteItem(dynamoTable, key)
  • dynamoTable : table's name
  • key : hashkey to delete

Secret Manager tools

Configure secret manager tools

const awsUtils = require('@voodoo.io/aws-utils').secretManager;

const aws = require('aws-sdk');
aws.config.update({region: 'eu-west-1'});
const cli = new aws.SecretsManager({});
const secretManagerTools = new awsUtils(cli);

getSecretValue

const res = await secretManagerTools.getSecretValue('secret');
getSecretValue(secret)
  • secret : secret's id

S3 tools

Configure S3 tools

const awsUtils = require('@voodoo.io/aws-utils').s3;

const aws = require('aws-sdk');
aws.config.update({region: 'eu-west-1'});
const cli = new aws.S3();
const s3Tools = new awsUtils(cli);

getObject

const res = await s3Tools.getObject('bucket', 'key');
getObject(bucket, key)
  • bucket : bucket's name
  • key : path to the ressource (/path/file.json)

putJsonObject

const res = await s3Tools.putJsonObject('bucket', 'key', {"key": "value"});
putJsonObject(bucket, key, item)
  • bucket : bucket's name
  • key : path to the ressource (/path/file.json)
  • item : json object to save on S3

emptyS3Directory

const res = await s3Tools.emptyS3Directory('bucket', 'dir/');
emptyS3Directory(bucket, dir)
  • bucket : bucket's name
  • dir : directory to remove

Test

$ npm test

Coverage report can be found in coverage/.

Keywords

FAQs

Package last updated on 17 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc