pomegranate-aws-sdk v3.0.1
Pomegranate AWS SDK
Provides promisified AWS APIs made available on the injector param AWS
.
Install
yarn add pomegranate pomegranate-aws-sdk
# Or..
npm i -S pomegranate pomegranate-aws-sdk
Configuration
This plugin exposes 3 configuration options.
The awsApis
option accepts an array of AWS service name strings and/or objects that contain a name property
and optionally an options property that will be passed to the service when it is instantiated.
The awsConfig
option will be passed as-is to AWS-SDK
.
The apiVersions
option can be used to specify the version string of the APIs in use.
exports.AwsSdk = function(Env){
return {
awsApis: ['S3', {name: 'SNS', options: {maxRetries: 5}}]
},
awsConfig: {
region: 'us-east-1'
},
apiVersions: {
s3: '2006-03-01',
SNS: '2010-03-31'
}
}
Usage
The plugin adds an AWS
property to the Pomegranate dependency injector, this object will contain instantiated,
configured objects with property names corresponding to the services you provided in its config file.
It also exposes a helper method AWS#isAvailable(string)
for use by downstream plugins who wish to determine if
a plugin is available.
Available AWS APIs
Please see http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/ sidebar for supported services.
The AWS objects outside of the services Namespace should be considered "Advanced Usage" and treated with caution.
Detailed Documentation
Table of Contents
index.js
Meta
- author: Jim Bulkowski <jim.b@paperelectron.com>
- license: MIT {@link http://opensource.org/licenses/MIT}
./lib/loader.js
Meta
- author: Jim Bulkowski <jim.b@paperelectron.com>
- license: MIT {@link http://opensource.org/licenses/MIT}
pomegranate-aws-sdk
A configurable loader for the Javascript AWS-SDK Returns an object available as "AWS" containing the configured AWS-SDK objects, as well as helper functions.
Returns awsApis
options
configureable options for this Plugin.
Properties
workDir
string Working directory containing AWS mock object files.awsApis
array<(string | {name: string, options: object})> AWS Services that will be loaded into the base AWS injectable object. Can be either a string of the name of the AWS service, or an object with name and options parameters.awsConfig
object Global AWS configuration that will be provided to aws-sdk before any services are instantiated.apiVersions
object Api versions this plugin will use, also loaded before any services are instantiated.useMocks
boolean Load mock AWS objects instead.
metadata
Pomegranate Metadata
Properties
name
string AwsSDK - Downstream dependencies can use this name in depends array.type
string service - This plugin returns a single object.param
string AWS - Injector parameter name.
awsApis
The Main object created by this plugin, containing all of the configured AWS service instances available for use by any downstream plugin.
Properties
AWS_Service_Name
object A dynamic property storing the configured AWS API instance. there will be one for every service listed in the options.awsApis array setting.
isAvailable
Determines if an AWS API is available on the injector
Parameters
serviceString
string
Examples
let AWS = inject('AWS')
let hasS3 = AWS.isAvailable('S3') // true
Returns boolean
addApiObject
Allows downstream plugins to add additional AWS service APis to this plugins injectable object.
Parameters
opts
Object
Examples
let S3Mock = require('some/mock/class.js')
let AWS = inject('AWS')
AWS.addApiObject({AwsApi: 'S3', MockClass: S3Mock})
AWS.S3.listBuckets()
.then(console.log)
Returns boolean true if added, false if it already existed.